client-c  0.8.1
ext_log_storage.h File Reference

External log storage interface used by Kaa data collection subsystem to temporarily store the logs before sending them to Operations server. Must be implemented in a concrete application for the data collection feature to function. More...

#include <stddef.h>
#include "../kaa_error.h"
+ Include dependency graph for ext_log_storage.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  kaa_log_record_t
 

Functions

kaa_error_t ext_log_storage_allocate_log_record_buffer (void *context, kaa_log_record_t *record)
 Allocates the data buffer to serialize a log entry into. More...
 
kaa_error_t ext_log_storage_deallocate_log_record_buffer (void *context, kaa_log_record_t *record)
 Deallocates the data buffer of a log record. More...
 
kaa_error_t ext_log_storage_add_log_record (void *context, kaa_log_record_t *record)
 Adds a log entry to the log storage. More...
 
kaa_error_t ext_log_storage_write_next_record (void *context, char *buffer, size_t buffer_len, uint16_t *bucket_id, size_t *record_len)
 Writes the next unmarked log entry into the supplied buffer and marks it with bucket_id the record size does not exceed the buffer_len. More...
 
kaa_error_t ext_log_storage_remove_by_bucket_id (void *context, uint16_t bucket_id)
 Removes from the storage all records marked with the provided bucket_id. More...
 
kaa_error_t ext_log_storage_unmark_by_bucket_id (void *context, uint16_t bucket_id)
 Unmarks all records marked with the provided bucket_id. More...
 
size_t ext_log_storage_get_total_size (const void *context)
 Returns total size occupied by logs in the log storage. More...
 
size_t ext_log_storage_get_records_count (const void *context)
 Returns total log records count. More...
 
kaa_error_t ext_log_storage_destroy (void *context)
 Destroys the log storage (which may decide to self-destroy). More...
 

Detailed Description

External log storage interface used by Kaa data collection subsystem to temporarily store the logs before sending them to Operations server. Must be implemented in a concrete application for the data collection feature to function.

Copyright 2014-2016 CyberVision, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition in file ext_log_storage.h.

Function Documentation

kaa_error_t ext_log_storage_add_log_record ( void *  context,
kaa_log_record_t record 
)

Adds a log entry to the log storage.

In case of success assumes ownership of the record data buffer. (No need to call ext_log_storage_destroy_log_record_buffer.)

Parameters
[in]contextLog storage context.
[in]recordLog record to add to log storage.
Returns
Error code.
kaa_error_t ext_log_storage_allocate_log_record_buffer ( void *  context,
kaa_log_record_t record 
)

Allocates the data buffer to serialize a log entry into.

Allocates the data buffer of size bytes in the record.

Parameters
[in]contextLog storage context.
[in,out]recordLog record to allocate buffer to.
Returns
Error code.
kaa_error_t ext_log_storage_deallocate_log_record_buffer ( void *  context,
kaa_log_record_t record 
)

Deallocates the data buffer of a log record.

Deallocates the data buffer in the record and sets size to 0.

Parameters
[in]contextLog storage context.
[in,out]recordLog record to deallocate buffer of.
Returns
Error code.
kaa_error_t ext_log_storage_destroy ( void *  context)

Destroys the log storage (which may decide to self-destroy).

Parameters
[in]contextLog storage context.
Returns
Error code
size_t ext_log_storage_get_records_count ( const void *  context)

Returns total log records count.

Parameters
[in]contextLog storage context.
Returns
Total amount of log records in the storage. Zero in case of errors.
size_t ext_log_storage_get_total_size ( const void *  context)

Returns total size occupied by logs in the log storage.

Parameters
[in]contextLog storage context.
Returns
Total log storage size in bytes, occupied by log records. Zero in case of errors.
kaa_error_t ext_log_storage_remove_by_bucket_id ( void *  context,
uint16_t  bucket_id 
)

Removes from the storage all records marked with the provided bucket_id.

Parameters
[in]contextLog storage context.
[in]bucket_idNon-zero bucket ID to search for records to be removed.
Returns
Error code
kaa_error_t ext_log_storage_unmark_by_bucket_id ( void *  context,
uint16_t  bucket_id 
)

Unmarks all records marked with the provided bucket_id.

Parameters
[in]contextLog storage context.
[in]bucket_idNon-zero bucket ID to search for records to be unmarked.
Returns
Error code
kaa_error_t ext_log_storage_write_next_record ( void *  context,
char *  buffer,
size_t  buffer_len,
uint16_t *  bucket_id,
size_t *  record_len 
)

Writes the next unmarked log entry into the supplied buffer and marks it with bucket_id the record size does not exceed the buffer_len.

Parameters
[in]contextLog storage context.
[in]bufferBuffer to write next unmarked record into.
[in]buffer_lenBuffer length in bytes.
[out]bucket_idOptional bucket ID of the next record.
[out]record_lenSize of the record data.
Returns
Error code: KAA_ERR_NONE when a record of record_len was successfully written into the buffer. KAA_ERR_NOT_FOUND when there were no unmarked records in the storage. record_len is set to 0 in this case. KAA_ERR_INSUFFICIENT_BUFFER when the buffer size was not sufficient to fit in the next unmarked entry. record_len is set to the size of the record that was not written.