![]() |
Kea 2.7.3
|
Represents a single entry in the audit table. More...
#include <audit_entry.h>
Public Types | |
enum class | ModificationType : uint8_t { CREATE = 0 , UPDATE = 1 , DELETE = 2 } |
Types of the modifications. More... | |
Public Member Functions | |
AuditEntry (const std::string &object_type, const uint64_t object_id, const ModificationType &modification_type, const boost::posix_time::ptime &modification_time, const uint64_t revision_id, const std::string &log_message) | |
Constructor using explicit modification time and id. | |
AuditEntry (const std::string &object_type, const uint64_t object_id, const ModificationType &modification_type, const uint64_t revision_id, const std::string &log_message) | |
Constructor using default modification time. | |
std::string | getLogMessage () const |
Returns log message. | |
boost::posix_time::ptime | getModificationTime () const |
Returns modification time. | |
ModificationType | getModificationType () const |
Returns modification type. | |
uint64_t | getObjectId () const |
Returns object id. | |
std::string | getObjectType () const |
Returns object type. | |
uint64_t | getRevisionId () const |
Returns revision id. | |
Static Public Member Functions | |
static AuditEntryPtr | create (const std::string &object_type, const uint64_t object_id, const ModificationType &modification_type, const boost::posix_time::ptime &modification_time, const uint64_t revision_id, const std::string &log_message) |
Factory function creating an instance of AuditEntry . | |
static AuditEntryPtr | create (const std::string &object_type, const uint64_t object_id, const ModificationType &modification_type, const uint64_t revision_id, const std::string &log_message) |
Factory function creating an instance of AuditEntry . | |
Represents a single entry in the audit table.
The audit tables are used in the databases to track incremental changes, e.g. configuration changes applied via the configuration backend. The backend can query for the entries in the audit table to identify the SQL table in which the records were modified, the identifiers of the modified objects, type of the modifications, time of the modifications and optional log messages associated with the modifications.
The server should remember the most recent modification time out of all audit entries it has fetched. During the next attempt to fetch the most recent modifications in the database it will query for all entries with later modification time than stored. That way the server queries only for the audit entries it hasn't fetched yet. In the case two (or more) successive audit entries have the same modification time the strictly increasing modification id is used.
When the modification type of the entry is set to AuditEntry::ModificationType::DELETE
, the corresponding configuration entry is already gone from the database. For example: when a subnet with ID of 123 is deleted from the dhcp4_subnet table, the audit entry similar to this will be stored in the audit table:
The subnet is instantly removed from the dhcp4_subnet table. When the server finds such entry in the audit table, it removes the subnet 123 from its (in-memory) configuration. There is no need make additional queries to fetch updated data from the dhcp4_subnet table, unless there are also audit entries indicating that some new subnets have been added or some subnets have been updated.
Definition at line 66 of file audit_entry.h.
|
strong |
Types of the modifications.
The numbers representing those modification types correspond to the values representing them in the database.
Enumerator | |
---|---|
CREATE | |
UPDATE | |
DELETE |
Definition at line 73 of file audit_entry.h.
isc::db::AuditEntry::AuditEntry | ( | const std::string & | object_type, |
const uint64_t | object_id, | ||
const ModificationType & | modification_type, | ||
const boost::posix_time::ptime & | modification_time, | ||
const uint64_t | revision_id, | ||
const std::string & | log_message ) |
Constructor using explicit modification time and id.
object_type | name of the table where data was modified. |
object_id | identifier of the modified record in this table. |
modification_type | type of the modification, e.g. DELETE. |
modification_time | time of modification for that record. |
revision_id | identifier of the revision. |
log_message | optional log message associated with the modification. |
Definition at line 16 of file audit_entry.cc.
isc::db::AuditEntry::AuditEntry | ( | const std::string & | object_type, |
const uint64_t | object_id, | ||
const ModificationType & | modification_type, | ||
const uint64_t | revision_id, | ||
const std::string & | log_message ) |
Constructor using default modification time.
object_type | name of the table where data was modified. |
object_id | identifier of the modified record in this table. |
modification_type | type of the modification, e.g. DELETE. |
revision_id | identifier of the revision. |
log_message | optional log message associated with the modification. |
Definition at line 32 of file audit_entry.cc.
|
static |
Factory function creating an instance of AuditEntry
.
This function should be used to create an instance of the audit entry within a hooks library in cases when the library may be unloaded before the object is destroyed. This ensures that the ownership of the object by the Kea process is retained.
object_type | name of the table where data was modified. |
object_id | identifier of the modified record in this table. |
modification_type | type of the modification, e.g. DELETE. |
modification_time | time of modification for that record. |
revision_id | identifier of the revision. |
log_message | optional log message associated with the modification. |
AuditEntry
instance. Definition at line 48 of file audit_entry.cc.
|
static |
Factory function creating an instance of AuditEntry
.
This function should be used to create an instance of the audit entry within a hooks library in cases when the library may be unloaded before the object is destroyed. This ensures that the ownership of the object by the Kea process is retained.
object_type | name of the table where data was modified. |
object_id | identifier of the modified record in this table. |
modification_type | type of the modification, e.g. DELETE. |
revision_id | identifier of the revision. |
log_message | optional log message associated with the modification. |
AuditEntry
instance. Definition at line 62 of file audit_entry.cc.
|
inline |
Returns log message.
Definition at line 194 of file audit_entry.h.
|
inline |
Returns modification time.
Definition at line 177 of file audit_entry.h.
|
inline |
Returns modification type.
Definition at line 170 of file audit_entry.h.
|
inline |
Returns object id.
Definition at line 163 of file audit_entry.h.
|
inline |
Returns object type.
Definition at line 156 of file audit_entry.h.
|
inline |
Returns revision id.
The revision id is used when two audit entries have the same modification time.
Definition at line 187 of file audit_entry.h.