This file implements MCL Store Interface. More...
#include "store.h"
#include "time_series.h"
#include "custom_data.h"
#include "stream_data.h"
#include "data_source_configuration.h"
#include "event_list.h"
#include "file.h"
#include "log_util.h"
#include "memory.h"
#include "definitions.h"
#include "mcl/mcl_store.h"
#include "time_util.h"
Go to the source code of this file.
Data Structures | |
struct | item_meta_payload_local_t |
Enumerations | |
enum | E_STORE_DATA_PRIORITY { PRIORITY_HIGH, PRIORITY_LOW } |
enum | E_EVENT_VERSION { EVENT_VERSION_1_0 = 0, EVENT_VERSION_2_0, EVENT_VERSION_END } |
Variables | |
static const string_t | _event_versions [EVENT_VERSION_END] |
static mcl_int32_t | _event_severity_values [EVENT_VERSION_END][MCL_EVENT_SEVERITY_END] |
This file implements MCL Store Interface.
Definition in file store.c.
enum E_EVENT_VERSION |
|
static |
Definition at line 468 of file store.c.
References store_data_t::data, DEBUG_ENTRY, DEBUG_LEAVE, MCL_DEBUG, MCL_FAIL, MCL_OK, event_list_t::meta, item_meta_t::payload, STORE_DATA_EVENT_LIST, string_compare_with_cstr(), item_meta_payload_local_t::type, store_data_t::type, item_meta_payload_t::type, item_meta_payload_local_t::version, and item_meta_payload_t::version.
Referenced by mcl_store_new_event().
|
static |
Definition at line 515 of file store.c.
References DEBUG_ENTRY, DEBUG_LEAVE, MCL_FALSE, and MCL_TRUE.
Referenced by _is_valid_version().
|
static |
Definition at line 491 of file store.c.
References _is_positive_integer(), DEBUG_ENTRY, DEBUG_LEAVE, string_util_find(), and string_util_strlen().
Referenced by mcl_store_new_data_source_configuration(), mcl_store_new_file(), mcl_store_new_stream_data(), and mcl_store_new_time_series().
|
static |
Definition at line 375 of file store.c.
References ASSERT_CODE_MESSAGE, ASSERT_STATEMENT_CODE_MESSAGE, store_data_t::data, DATA_STATE_INITIAL, DEBUG_ENTRY, DEBUG_LEAVE, list_add(), MCL_FREE, MCL_NEW, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, store_data_t::meta, store_data_t::payload_buffer, store_data_t::payload_size, PRIORITY_HIGH, store_data_t::state, store_data_t::stream_info, and store_data_t::type.
Referenced by mcl_store_new_custom_data(), mcl_store_new_data_source_configuration(), mcl_store_new_event(), mcl_store_new_file(), mcl_store_new_stream_data(), and mcl_store_new_time_series().
void _store_list_destroy_callback | ( | void ** | item | ) |
Definition at line 403 of file store.c.
References custom_data_destroy(), store_data_t::data, data_source_configuration_destroy(), DEBUG_ENTRY, DEBUG_LEAVE, event_list_destroy(), file_destroy(), MCL_DEBUG, MCL_FATAL, MCL_FREE, MCL_NULL, store_data_t::meta, store_data_t::payload_buffer, STORE_DATA_CUSTOM, STORE_DATA_DATA_SOURCE_CONFIGURATION, STORE_DATA_EVENT_LIST, STORE_DATA_FILE, STORE_DATA_STREAM, STORE_DATA_TIME_SERIES, stream_data_destroy(), store_data_t::stream_info, string_destroy(), time_series_destroy(), store_data_stream_info_t::tuple_subboundary, and store_data_t::type.
Referenced by mcl_store_destroy(), and store_data_remove().
E_MCL_ERROR_CODE mcl_store_destroy | ( | mcl_store_t ** | store | ) |
This function destroys the mcl_store_t object and frees any memory allocated.
[in] | store | Preinitialized mcl_store_t object to destroy. |
store
is NULL. Definition at line 312 of file store.c.
References _store_list_destroy_callback(), ASSERT_NOT_NULL, DEBUG_ENTRY, DEBUG_LEAVE, list_destroy_with_content(), MCL_DEBUG, MCL_FREE, MCL_NULL, and MCL_OK.
Referenced by mcl_store_initialize().
E_MCL_ERROR_CODE mcl_store_initialize | ( | mcl_bool_t | streamable, |
mcl_store_t ** | store | ||
) |
This function creates and initializes an object of type mcl_store_t.
Store is used to hold different types of data. These data will be processed later by mcl_communication module to perform exchange operation. A store can be initialized as streamable or non-streamable (streamable
). During exchange operation, data of a Non-Streamable store will be sent to MindSphere using a normal HTTP message, while the data of a streamable store will be sent using chunked Transfer-Encoding.
[in] | streamable | Indicates if the content of this store will be exchanged using chunked Transfer-Encoding or not. |
[out] | store | The newly initialized store. |
store
is NULL. Definition at line 68 of file store.c.
References ASSERT_CODE_MESSAGE, ASSERT_NOT_NULL, ASSERT_STATEMENT_CODE_MESSAGE, DEBUG_ENTRY, DEBUG_LEAVE, list_initialize(), MCL_DEBUG, MCL_FAIL, MCL_FALSE, MCL_NEW, MCL_NULL, MCL_OK, MCL_OPERATION_IS_NOT_SUPPORTED, MCL_OUT_OF_MEMORY, and mcl_store_destroy().
E_MCL_ERROR_CODE mcl_store_new_custom_data | ( | mcl_store_t * | store, |
const char * | version, | ||
const char * | type, | ||
const char * | routing, | ||
mcl_custom_data_t ** | custom_data | ||
) |
This function creates and initializes a new mcl_custom_data_t structure.
[in] | store | MCL store which will contain the new mcl_custom_data_t structure created. |
[in] | version | Version of the custom_data. |
[in] | type | Type of the custom_data. |
[in] | routing | Routing information which is optional. NULL can be given to use the default parser. |
[out] | custom_data | Created and initialized mcl_custom_data_t object. |
store
. Definition at line 230 of file store.c.
References _store_add_data(), ASSERT_CODE_MESSAGE, ASSERT_NOT_NULL, ASSERT_STATEMENT_CODE_MESSAGE, custom_data_destroy(), custom_data_initialize(), DEBUG_ENTRY, DEBUG_LEAVE, MCL_OK, PRIORITY_HIGH, and STORE_DATA_CUSTOM.
E_MCL_ERROR_CODE mcl_store_new_data_source_configuration | ( | mcl_store_t * | store, |
const char * | version, | ||
mcl_data_source_configuration_t ** | data_source_configuration | ||
) |
This function creates and initializes a new mcl_data_source_configuration_t structure.
[in] | store | MCL store which will contain the new mcl_data_source_configuration_t structure created. |
[in] | version | Version of the data_source_configuration . Format must be in the form of MAJOR.MINOR where major and minor are non-negative integers. |
[out] | data_source_configuration | Created and initialized mcl_data_source_configuration_t object. |
store
. Definition at line 286 of file store.c.
References _is_valid_version(), _store_add_data(), ASSERT_CODE_MESSAGE, ASSERT_NOT_NULL, ASSERT_STATEMENT_CODE_MESSAGE, data_source_configuration_destroy(), data_source_configuration_initialize(), DEBUG_ENTRY, DEBUG_LEAVE, MCL_INVALID_PARAMETER, MCL_OK, MCL_TRUE, PRIORITY_HIGH, and STORE_DATA_DATA_SOURCE_CONFIGURATION.
E_MCL_ERROR_CODE mcl_store_new_event | ( | mcl_store_t * | store, |
const char * | version, | ||
const char * | type, | ||
const char * | type_version, | ||
E_MCL_EVENT_SEVERITY | severity, | ||
const char * | timestamp, | ||
mcl_event_t ** | event | ||
) |
This function creates and initializes a new mcl_event_t structure.
[in] | store | MCL store which will contain the new mcl_event_t structure created. |
[in] | version | Version of event. Format must be in the form of MAJOR.MINOR where major and minor are non-negative integers. |
[in] | type | Type of event. |
[in] | type_version | Version of event type. |
[in] | severity | Severity level declared in E_MCL_EVENT_SEVERITY. |
[in] | timestamp | Timestamp of the event in YYYY-MM-DDThh:mm:ss.sssZ format. Ex:2016-04-26T08:06:25.317Z. |
[out] | event | Created and initialized event data struct. |
store
. Definition at line 125 of file store.c.
References _compare_item_meta_of_event(), _event_severity_values, _store_add_data(), ASSERT_CODE_MESSAGE, ASSERT_NOT_NULL, ASSERT_STATEMENT_CODE_MESSAGE, string_t::buffer, store_data_t::data, DEBUG_ENTRY, DEBUG_LEAVE, event_destroy(), event_initialize(), event_list_add_event(), event_list_destroy(), event_list_initialize(), EVENT_VERSION_END, list_exist(), MCL_EVENT_SEVERITY_END, MCL_EVENT_SEVERITY_ERROR, MCL_FAIL, MCL_INVALID_PARAMETER, MCL_NULL, MCL_OK, MCL_TRUE, event_list_t::meta, META_FIELD_PAYLOAD_TYPE_BUSINESS_EVENT, meta_field_values, PRIORITY_HIGH, STORE_DATA_EVENT_LIST, string_compare_with_cstr(), time_util_validate_timestamp(), item_meta_payload_local_t::type, and item_meta_payload_local_t::version.
E_MCL_ERROR_CODE mcl_store_new_file | ( | mcl_store_t * | store, |
const char * | version, | ||
const char * | file_path, | ||
const char * | file_name, | ||
const char * | file_type, | ||
const char * | routing, | ||
mcl_file_t ** | file | ||
) |
This function creates and initializes a new mcl_file_t structure.
[in] | store | MCL store which will contain the new mcl_file_t structure created. |
[in] | version | Version of file type. Format must be in the form of MAJOR.MINOR where major and minor are non-negative integers. |
[in] | file_path | Path of the file to be added to store. |
[in] | file_name | Name of the file. This name will be assigned to the file that is being uploaded. |
[in] | file_type | Type of the file. |
[in] | routing | Routing information which is optional. NULL can be given to use the default parser. |
[out] | file | Created and initialized file data struct. |
store
. Definition at line 196 of file store.c.
References _is_valid_version(), _store_add_data(), ASSERT_CODE_MESSAGE, ASSERT_NOT_NULL, ASSERT_STATEMENT_CODE_MESSAGE, DEBUG_ENTRY, DEBUG_LEAVE, file_destroy(), file_initialize(), MCL_ERROR, MCL_FAIL, MCL_INVALID_PARAMETER, MCL_OK, MCL_TRUE, PRIORITY_HIGH, and STORE_DATA_FILE.
E_MCL_ERROR_CODE mcl_store_new_stream_data | ( | mcl_store_t * | store, |
const char * | version, | ||
const char * | type, | ||
const char * | routing, | ||
mcl_stream_data_read_callback_t | stream_data_read_callback, | ||
void * | user_context, | ||
mcl_stream_data_t ** | stream_data | ||
) |
This function creates and initializes a new streamable mcl_stream_data_t structure.
With this data type, user can specify a callback and context to fill the payload of the custom data. The callback will be called while performing the send operation.
[in] | store | MCL store which will contain the new mcl_stream_data_t structure created. |
[in] | version | Version of the stream_data. Format must be in the form of MAJOR.MINOR where major and minor are non-negative integers. |
[in] | type | Type of the stream_data. |
[in] | routing | Routing information which is optional. NULL can be given to use the default parser. |
[in] | stream_data_read_callback | Stream data read callback function. |
[in] | user_context | User context used to sent to the callback function. |
[out] | stream_data | Created and initialized stream_data data struct. |
store
, version
, type
or stream_data
is NULL. store
is not streamable or version format is not correct. store
. Definition at line 255 of file store.c.
References _is_valid_version(), _store_add_data(), ASSERT_CODE_MESSAGE, ASSERT_NOT_NULL, ASSERT_STATEMENT_CODE_MESSAGE, DEBUG_ENTRY, DEBUG_LEAVE, MCL_INVALID_PARAMETER, MCL_OK, MCL_TRUE, PRIORITY_HIGH, STORE_DATA_STREAM, stream_data_destroy(), and stream_data_initialize().
E_MCL_ERROR_CODE mcl_store_new_time_series | ( | mcl_store_t * | store, |
const char * | version, | ||
const char * | configuration_id, | ||
const char * | routing, | ||
mcl_time_series_t ** | time_series | ||
) |
This function creates and initializes a new mcl_time_series_t structure.
[in] | store | MCL store which will contain the new mcl_time_series_t structure created. |
[in] | version | Version of the time series data. Format must be in the form of MAJOR.MINOR where major and minor are non-negative integers. |
[in] | configuration_id | Configuration ID of the time series data. |
[in] | routing | Routing information which is optional. NULL can be given to use the default parser. |
[out] | time_series | Created and initialized time series data struct. |
store
. Definition at line 98 of file store.c.
References _is_valid_version(), _store_add_data(), ASSERT_CODE_MESSAGE, ASSERT_NOT_NULL, ASSERT_STATEMENT_CODE_MESSAGE, DEBUG_ENTRY, DEBUG_LEAVE, MCL_INVALID_PARAMETER, MCL_OK, MCL_TRUE, PRIORITY_HIGH, STORE_DATA_TIME_SERIES, time_series_destroy(), and time_series_initialize().
E_STORE_DATA_STATE store_data_get_state | ( | store_data_t * | store_data | ) |
This function is used to get the state of the data.
[in] | store_data | Current store data. |
Definition at line 345 of file store.c.
References DEBUG_ENTRY, DEBUG_LEAVE, MCL_DEBUG, and store_data_t::state.
Referenced by _exchange_clear_sent_data_from_store(), _exchange_fill_http_request(), and _exchange_update_store_data_state().
E_MCL_ERROR_CODE store_data_remove | ( | list_t * | store_list, |
list_node_t * | store_data_node | ||
) |
This function is used to remove a store data from the store.
Needs to know in which list ( high_priority_list or low_priority_list ) this data resides.
[in] | store_list | The list in the store holding the data. |
[in] | store_data_node | List node of the data requested to be removed. |
store_list
is empty. Definition at line 355 of file store.c.
References _store_list_destroy_callback(), DEBUG_ENTRY, DEBUG_LEAVE, and list_remove_with_content().
Referenced by _exchange_clear_sent_data_from_store().
void store_data_set_state | ( | store_data_t * | store_data, |
E_STORE_DATA_STATE | state | ||
) |
This function is used to set the state of the store data.
[in] | store_data | Current store data. |
[in] | state | New state of the data. |
Definition at line 334 of file store.c.
References DEBUG_ENTRY, DEBUG_LEAVE, MCL_DEBUG, and store_data_t::state.
Referenced by _exchange_add_current_data_to_request(), _exchange_add_current_data_to_request_by_streaming(), _exchange_fill_http_request(), _exchange_prepare_data(), and _exchange_update_store_data_state().
mcl_size_t store_get_data_count | ( | store_t * | store | ) |
This function is used to get the count of items in store.
[in] | store | The store handle. |
Definition at line 366 of file store.c.
References mcl_list_t::count, DEBUG_ENTRY, DEBUG_LEAVE, store_t::high_priority_list, and store_t::low_priority_list.
Referenced by http_processor_exchange(), and http_processor_stream().
|
static |
Definition at line 52 of file store.c.
Referenced by mcl_store_new_event().
|
static |