diff options
Diffstat (limited to 'src/plugins/supervisor-api.c')
-rw-r--r-- | src/plugins/supervisor-api.c | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/src/plugins/supervisor-api.c b/src/plugins/supervisor-api.c index 50e4808..33e52c6 100644 --- a/src/plugins/supervisor-api.c +++ b/src/plugins/supervisor-api.c @@ -36,7 +36,7 @@ static int* TracePidsArr = NULL; nb++; \ json_object_array_add(res, json_object_new_int(dd->pid)); \ if ((rc = trace_daemon(src->api, dd, lvl)) < 0) { \ - AFB_ReqFailF(src->request, "failed", "Trace pid %d error %d", dd->pid, rc); \ + afb_req_fail_f(src->request, "failed", "Trace pid %d error %d", dd->pid, rc); \ goto error; \ } \ } @@ -55,11 +55,11 @@ CTLP_CAPI(list, source, argsJ, eventJ) getDaemons(source->api, &daemons); if (daemons == NULL) { - AFB_ReqFail(source->request, "Failed", "Error daemon list null"); + afb_req_fail(source->request, "Failed", "Error daemon list null"); return ERROR; } - AFB_ApiInfo(source->api, "Build response (nb daemons %d)", daemons->count); + AFB_API_INFO(source->api, "Build response (nb daemons %d)", daemons->count); result = json_object_new_array(); for (int i = 0; i < daemons->count; i++) { @@ -75,8 +75,8 @@ CTLP_CAPI(list, source, argsJ, eventJ) json_object_array_add(result, item); } - AFB_ApiInfo(source->api, "Send response"); - AFB_ReqSuccess(source->request, result, NULL); + AFB_API_INFO(source->api, "Send response"); + afb_req_success(source->request, result, NULL); return 0; } @@ -95,27 +95,27 @@ CTLP_CAPI(trace_start, source, argsJ, queryJ) // a specific pid or an array of pids or a specific ws name if (wrap_json_unpack(queryJ, "{s:?i s:?o s:?s s:?s}", "pid", &pid, "pids", &j_pids, "ws", &ws_name, "level", &level)) { - AFB_ReqFail(source->request, "Failed", "Error processing arguments."); + afb_req_fail(source->request, "Failed", "Error processing arguments."); return ERROR; } if (pid == -1 && j_pids == NULL && strlen(ws_name) == 0) { - AFB_ReqFail(source->request, "failed", "one of pid or pids or ws parameter must be set"); + afb_req_fail(source->request, "failed", "one of pid or pids or ws parameter must be set"); return ERROR; } if (TracePidsNum > 0) { - AFB_ReqFail(source->request, "failed", "already tracing"); + afb_req_fail(source->request, "failed", "already tracing"); return ERROR; } - AFB_ApiDebug(source->api, "Trace ws=%s, pid=%d, pids=%s", ws_name, pid, json_object_to_json_string(j_pids)); + AFB_API_DEBUG(source->api, "Trace ws=%s, pid=%d, pids=%s", ws_name, pid, json_object_to_json_string(j_pids)); if (j_pids != NULL && json_object_is_type(j_pids, json_type_array)) { TracePidsNum = (int)json_object_array_length(j_pids); TracePidsArr = malloc(sizeof(int) * TracePidsNum); if (TracePidsArr == NULL) { - AFB_ReqFail(source->request, "failed", "out of memory"); + afb_req_fail(source->request, "failed", "out of memory"); goto error; } int i = 0; @@ -127,7 +127,7 @@ CTLP_CAPI(trace_start, source, argsJ, queryJ) getDaemons(source->api, &daemons); if (daemons == NULL || daemons->count <= 0) { - AFB_ReqFail(source->request, "failed", "No daemon found"); + afb_req_fail(source->request, "failed", "No daemon found"); goto error; } @@ -136,9 +136,9 @@ CTLP_CAPI(trace_start, source, argsJ, queryJ) nb_traced_daemons = 0; result = json_object_new_array(); for (int i = 0; i < daemons->count; i++) { - AFB_ApiDebug(source->api, "_DEBUG_ svr %s", + AFB_API_DEBUG(source->api, "_DEBUG_ svr %s", json_object_to_json_string(daemons->daemons[i]->ws_servers)); - AFB_ApiDebug(source->api, "_DEBUG_ cli %s", + AFB_API_DEBUG(source->api, "_DEBUG_ cli %s", json_object_to_json_string(daemons->daemons[i]->ws_clients)); if (pid != -1 && pid == daemons->daemons[i]->pid) { @@ -147,7 +147,7 @@ CTLP_CAPI(trace_start, source, argsJ, queryJ) TracePidsNum = 1; TracePidsArr = malloc(sizeof(int) * TracePidsNum); if (TracePidsArr == NULL) { - AFB_ReqFail(source->request, "failed", "out of memory"); + afb_req_fail(source->request, "failed", "out of memory"); goto error; } TracePidsArr[0] = daemons->daemons[i]->pid; @@ -171,7 +171,7 @@ CTLP_CAPI(trace_start, source, argsJ, queryJ) TracePidsNum++; int* tmpPtr = realloc(TracePidsArr, sizeof(int) * TracePidsNum); if (tmpPtr == NULL) { - AFB_ReqFail(source->request, "failed", "out of memory"); + afb_req_fail(source->request, "failed", "out of memory"); goto error; } TracePidsArr = tmpPtr; @@ -189,7 +189,7 @@ CTLP_CAPI(trace_start, source, argsJ, queryJ) TracePidsNum++; int* tmpPtr = realloc(TracePidsArr, sizeof(int) * TracePidsNum); if (tmpPtr == NULL) { - AFB_ReqFail(source->request, "failed", "out of memory"); + afb_req_fail(source->request, "failed", "out of memory"); goto error; } TracePidsArr = tmpPtr; @@ -201,11 +201,11 @@ CTLP_CAPI(trace_start, source, argsJ, queryJ) } if (nb_traced_daemons == 0) { - AFB_ReqFail(source->request, "failed", "No daemon found match criteria"); + afb_req_fail(source->request, "failed", "No daemon found match criteria"); goto error; } - AFB_ReqSuccess(source->request, result, "Trace successfully started"); + afb_req_success(source->request, result, "Trace successfully started"); return 0; @@ -223,7 +223,7 @@ CTLP_CAPI(trace_stop, source, argsJ, queryJ) json_object* result = NULL; if (TracePidsNum == 0) { - AFB_ReqFail(source->request, "failed", "Trace already stopped"); + afb_req_fail(source->request, "failed", "Trace already stopped"); return ERROR; } @@ -240,10 +240,10 @@ CTLP_CAPI(trace_stop, source, argsJ, queryJ) TracePidsArr = NULL; if (nbErr) { - AFB_ReqFailF(source->request, "failed", "Error while stopping tracing (%d)", nbErr); + afb_req_fail_f(source->request, "failed", "Error while stopping tracing (%d)", nbErr); return ERROR; } - AFB_ReqSuccess(source->request, result, "Trace successfully stopped"); + afb_req_success(source->request, result, "Trace successfully stopped"); return 0; } @@ -259,7 +259,7 @@ uint64_t get_ts() static void cb_harvester_write(void* closure, int status, struct json_object* result, struct afb_dynapi* dynapi) { - AFB_ApiDebug(dynapi, "SEB cb_harvester_write"); + AFB_API_DEBUG(dynapi, "SEB cb_harvester_write"); } static int harvester_post_data(CtlSourceT* source, METRIC_T* metric) @@ -285,34 +285,34 @@ static int harvester_post_data(CtlSourceT* source, METRIC_T* metric) "values", "value", metric->data, "timestamp", metric->timestamp); } else { - AFB_ReqFail(source->request, "Failed", "Unsupported dataType"); + afb_req_fail(source->request, "Failed", "Unsupported dataType"); return ERROR; } if (rc < 0) { - AFB_ReqFail(source->request, "Failed", "Error packing metric, rc=%d", rc); + afb_req_fail(source->request, "Failed", "Error packing metric, rc=%d", rc); return rc; } rc = wrap_json_pack(&j_query, "{s:s s:i s:o }", "host", "localhost", "port", 8086, "metric", j_metric); if (rc < 0) { - AFB_ReqFail(source->request, "Failed", "Error packing query, rc=%d", rc); + afb_req_fail(source->request, "Failed", "Error packing query, rc=%d", rc); return rc; } - AFB_ApiDebug(source->api, "%s write: %s", SRV_HARVESTER_NAME, + AFB_API_DEBUG(source->api, "%s write: %s", SRV_HARVESTER_NAME, json_object_to_json_string(j_query)); /* SEB - rc = AFB_ServiceSync(source->api, SRV_HARVESTER_NAME, "write", j_query, &j_res); + rc = afb_api_call_sync_legacy(source->api, SRV_HARVESTER_NAME, "write", j_query, &j_res); if (rc < 0) { - AFB_ReqFail(source->request, "Failed", "Error %s write : rc=%d, j_res=%s", SRV_HARVESTER_NAME, rc, + afb_req_fail(source->request, "Failed", "Error %s write : rc=%d, j_res=%s", SRV_HARVESTER_NAME, rc, json_object_to_json_string(j_res)); return rc; } */ - AFB_ServiceCall(source->api, SRV_HARVESTER_NAME, "write", j_query, cb_harvester_write, &j_res); + afb_api_call_legacy(source->api, SRV_HARVESTER_NAME, "write", j_query, cb_harvester_write, &j_res); return 0; } @@ -326,25 +326,25 @@ CTLP_CAPI(tracing_events, source, argsJ, eventJ) //struct signalCBT* ctx = (struct signalCBT*)source->context; - AFB_ApiDebug(source->api, ">>> RECV Event uid %s : %s", source->uid, + AFB_API_DEBUG(source->api, ">>> RECV Event uid %s : %s", source->uid, json_object_to_json_string(eventJ)); if (strcmp(source->uid, "xds/supervisor/trace") != 0) { - AFB_ApiNotice(source->api, "WARNING: un-handle uid '%s'", source->uid); + AFB_API_NOTICE(source->api, "WARNING: un-handle uid '%s'", source->uid); return 0; } if ((rc = wrap_json_unpack(eventJ, "{s:?s}", "type", &type)) < 0) { - AFB_ReqFail(source->request, "Failed", "Cannot decode event type"); + afb_req_fail(source->request, "Failed", "Cannot decode event type"); return ERROR; } if (strcmp(type, "request") != 0) { - AFB_ReqFail(source->request, "Failed", "Cannot retrieve request"); + afb_req_fail(source->request, "Failed", "Cannot retrieve request"); return ERROR; } if (!json_object_object_get_ex(eventJ, "request", &request)) { - AFB_ReqFail(source->request, "Failed", "Cannot decode event request"); + afb_req_fail(source->request, "Failed", "Cannot decode event request"); return ERROR; } @@ -361,7 +361,7 @@ CTLP_CAPI(tracing_events, source, argsJ, eventJ) rc = harvester_post_data(source, &metric); if (rc < 0) { - AFB_ReqFail(source->request, "Failed", "ERROR harvester_post_data: rc %d", rc); + afb_req_fail(source->request, "Failed", "ERROR harvester_post_data: rc %d", rc); return rc; } |