AT&T ECOMP Vendor Event Listener library  0.1
Functions
evel_event_mgr.c File Reference

Event Manager. More...

#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include <pthread.h>
#include <curl/curl.h>
#include "evel.h"
#include "evel_internal.h"
#include "ring_buffer.h"
#include "evel_throttle.h"
Include dependency graph for evel_event_mgr.c:

Go to the source code of this file.

Functions

EVEL_ERR_CODES event_handler_initialize (const char *const event_api_url, const char *const throt_api_url, const char *const username, const char *const password, int verbosity)
 Initialize the event handler. More...
 
EVEL_ERR_CODES event_handler_run ()
 Run the event handler. More...
 
EVEL_ERR_CODES event_handler_terminate ()
 Terminate the event handler. More...
 
EVEL_ERR_CODES evel_post_event (EVENT_HEADER *event)
 Post an event. More...
 
size_t evel_write_callback (void *contents, size_t size, size_t nmemb, void *userp)
 Callback function to provide returned data. More...
 
void evel_handle_event_response (const MEMORY_CHUNK *const chunk, MEMORY_CHUNK *const post)
 Handle a JSON response from the listener, contained in a MEMORY_CHUNK. More...
 

Detailed Description

Event Manager.

Simple event manager that is responsible for taking events (Heartbeats, Faults and Measurements) from the ring-buffer and posting them to the API.

License

Copyright(c) <2016>, AT&T Intellectual Property. All other rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by the AT&T.
  4. Neither the name of AT&T nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY AT&T INTELLECTUAL PROPERTY ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AT&T INTELLECTUAL PROPERTY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file evel_event_mgr.c.

Function Documentation

§ evel_handle_event_response()

void evel_handle_event_response ( const MEMORY_CHUNK *const  chunk,
MEMORY_CHUNK *const  post 
)

Handle a JSON response from the listener, contained in a MEMORY_CHUNK.

Tokenize the response, and decode any tokens found.

Parameters
chunkThe memory chunk containing the response.
postThe memory chunk in which to place any resulting POST.

Definition at line 904 of file evel_event_mgr.c.

§ evel_post_event()

EVEL_ERR_CODES evel_post_event ( EVENT_HEADER event)

Post an event.

Note
So far as the caller is concerned, successfully posting the event relinquishes all responsibility for the event - the library will take care of freeing the event in due course.
Parameters
eventThe event to be posted.
Returns
Status code
Return values
EVEL_SUCCESSOn success
One of ::EVEL_ERR_CODESOn failure.

Definition at line 497 of file evel_event_mgr.c.

§ evel_write_callback()

size_t evel_write_callback ( void *  contents,
size_t  size,
size_t  nmemb,
void *  userp 
)

Callback function to provide returned data.

Copy data into the supplied buffer, write_callback::ptr, checking size limits.

Returns
Number of bytes placed into write_callback::ptr. 0 for EOF.

Definition at line 712 of file evel_event_mgr.c.

§ event_handler_initialize()

EVEL_ERR_CODES event_handler_initialize ( const char *const  event_api_url,
const char *const  throt_api_url,
const char *const  username,
const char *const  password,
int  verbosity 
)

Initialize the event handler.

Primarily responsible for getting CURL ready for use.

Parameters
[in]event_api_urlThe URL where the Vendor Event Listener API is expected to be.
[in]throt_api_urlThe URL where the Throttling API is expected to be.
[in]usernameThe username for the Basic Authentication of requests.
[in]passwordThe password for the Basic Authentication of requests.
verbosity0 for normal operation, positive values for chattier logs.

Definition at line 133 of file evel_event_mgr.c.

§ event_handler_run()

EVEL_ERR_CODES event_handler_run ( )

Run the event handler.

Spawns the thread responsible for handling events and sending them to the API.

Returns
Status code.
Return values
EVEL_SUCCESSif everything OK.
Oneof EVEL_ERR_CODES if there was a problem.

Definition at line 371 of file evel_event_mgr.c.

§ event_handler_terminate()

EVEL_ERR_CODES event_handler_terminate ( )

Terminate the event handler.

Shuts down the event handler thread in as clean a way as possible. Sets the global exit flag and then signals the thread to interrupt it since it's most likely waiting on the ring-buffer.

Having achieved an orderly shutdown of the event handler thread, clean up the cURL library's resources cleanly.

Returns
Status code.
Return values
EVEL_SUCCESSif everything OK.
Oneof EVEL_ERR_CODES if there was a problem.

Definition at line 408 of file evel_event_mgr.c.