X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=vnfs%2FVES5.0%2Fevel%2Fevel-library%2Fcode%2Fevel_library%2Fevel_event_mgr.c;h=9d3aa6107ca456f96313a70745961b62cf17aed0;hb=f9cbe4b0ecf250f970cd8ed37b4ba3e9e8af1396;hp=572df148984d4f562c32768086423ac0a6f89a1d;hpb=12fd5fcf0e58f79cd4666592dd0fc34090b298e7;p=demo.git diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event_mgr.c b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event_mgr.c index 572df148..9d3aa610 100644 --- a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event_mgr.c +++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event_mgr.c @@ -102,6 +102,7 @@ static EVT_HANDLER_STATE evt_handler_state = EVT_HANDLER_UNINITIALIZED; *****************************************************************************/ static char * evel_event_api_url; static char * evel_throt_api_url; +static char * evel_batch_api_url; /**************************************************************************//** * Initialize the event handler. @@ -126,6 +127,7 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, { int rc = EVEL_SUCCESS; CURLcode curl_rc = CURLE_OK; + char batch_api_url[EVEL_MAX_URL_LEN + 1] = {0}; EVEL_ENTER(); @@ -142,6 +144,9 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, /***************************************************************************/ evel_event_api_url = strdup(event_api_url); assert(evel_event_api_url != NULL); + sprintf(batch_api_url,"%s/eventBatch",event_api_url); + evel_batch_api_url = strdup(batch_api_url); + assert(evel_batch_api_url != NULL); evel_throt_api_url = strdup(throt_api_url); assert(evel_throt_api_url != NULL); @@ -790,7 +795,37 @@ static void * event_handler(void * arg __attribute__ ((unused))) /* Internal events get special treatment while regular events get posted */ /* to the far side. */ /*************************************************************************/ - if (msg->event_domain != EVEL_DOMAIN_INTERNAL) + if (msg->event_domain == EVEL_DOMAIN_BATCH ) + { + EVEL_DEBUG("Batch event received"); + + /***********************************************************************/ + /* Encode the event in JSON. */ + /***********************************************************************/ + json_size = evel_json_encode_batch_event(json_body, EVEL_MAX_JSON_BODY, msg); + + /***************************************************************************/ + /* Set the URL for the API. */ + /***************************************************************************/ + curl_rc = curl_easy_setopt(curl_handle, CURLOPT_URL, evel_batch_api_url); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the Batch API URL. " + "Error code=%d (%s)", curl_rc, curl_err_string); + } + + /***********************************************************************/ + /* Send the JSON across the API. */ + /***********************************************************************/ + EVEL_DEBUG("Sending Batch JSON of size %d is: %s", json_size, json_body); + rc = evel_post_api(json_body, json_size); + if (rc != EVEL_SUCCESS) + { + EVEL_ERROR("Failed to transfer the data. Error code=%d", rc); + } + } + else if (msg->event_domain != EVEL_DOMAIN_INTERNAL ) { EVEL_DEBUG("External event received"); @@ -799,6 +834,17 @@ static void * event_handler(void * arg __attribute__ ((unused))) /***********************************************************************/ json_size = evel_json_encode_event(json_body, EVEL_MAX_JSON_BODY, msg); + /***************************************************************************/ + /* Set the URL for the API. */ + /***************************************************************************/ + curl_rc = curl_easy_setopt(curl_handle, CURLOPT_URL, evel_event_api_url); + if (curl_rc != CURLE_OK) + { + rc = EVEL_CURL_LIBRARY_FAIL; + log_error_state("Failed to initialize libCURL with the API URL. " + "Error code=%d (%s)", curl_rc, curl_err_string); + } + /***********************************************************************/ /* Send the JSON across the API. */ /***********************************************************************/