DBM update logger with a message queue.
More...
#include <tkrzw_dbm_ulog.h>
DBM update logger with a message queue.
◆ OpType
Enumeration for operation types.
Enumerator |
---|
OP_VOID | Invalid operation.
|
OP_SET | To modify or add a record.
|
OP_REMOVE | To remove a record.
|
OP_CLEAR | To remove all records.
|
◆ DBMUpdateLoggerMQ()
tkrzw::DBMUpdateLoggerMQ::DBMUpdateLoggerMQ |
( |
MessageQueue * |
mq, |
|
|
int32_t |
server_id = 0 , |
|
|
int32_t |
dbm_index = 0 , |
|
|
int64_t |
fixed_timestamp = -1 |
|
) |
| |
|
explicit |
Constructor.
- Parameters
-
mq | The message queue object to store update logs. The ownership is not taken. |
server_id | The server ID of the process. |
dbm_index | The index of the DBM on the server. |
fixed_timestamp | If not negative, the timestamp is fixed to the value. |
◆ WriteSet()
Status tkrzw::DBMUpdateLoggerMQ::WriteSet |
( |
std::string_view |
key, |
|
|
std::string_view |
value |
|
) |
| |
|
overridevirtual |
Writes a log for modifying an existing record or adding a new record.
- Parameters
-
key | The key of the record. |
value | The new value of the record. |
- Returns
- The result status.
Implements tkrzw::DBM::UpdateLogger.
◆ WriteRemove()
Status tkrzw::DBMUpdateLoggerMQ::WriteRemove |
( |
std::string_view |
key | ) |
|
|
overridevirtual |
Writes a log for removing an existing record.
- Parameters
-
key | The key of the record. |
- Returns
- The result status.
Implements tkrzw::DBM::UpdateLogger.
◆ WriteClear()
Status tkrzw::DBMUpdateLoggerMQ::WriteClear |
( |
| ) |
|
|
overridevirtual |
◆ Synchronize()
Status tkrzw::DBMUpdateLoggerMQ::Synchronize |
( |
bool |
hard | ) |
|
|
overridevirtual |
Synchronizes the metadata and content to the file system.
- Parameters
-
hard | True to do physical synchronization with the hardware or false to do only logical synchronization with the file system. |
- Returns
- The result status.
Reimplemented from tkrzw::DBM::UpdateLogger.
◆ OverwriteThreadServerID()
static void tkrzw::DBMUpdateLoggerMQ::OverwriteThreadServerID |
( |
int32_t |
server_id | ) |
|
|
static |
Overwrites the server ID of the current thread.
- Parameters
-
server_id | The server ID of the process. If it is negative, the thread local setting is undone. If it is INT32MIN, logging of the current thread is disable. |
This affects logging of only the current thread regardless of the logger instance.
◆ ParseUpdateLog()
static Status tkrzw::DBMUpdateLoggerMQ::ParseUpdateLog |
( |
std::string_view |
message, |
|
|
UpdateLog * |
op |
|
) |
| |
|
static |
Parses an update log message.
- Parameters
-
message | The update log message. |
op | The pointer to the update log object to store the result. The life duration of the key and the value fields is the same as the given message. |
- Returns
- The result status.
◆ ApplyUpdateLog()
static Status tkrzw::DBMUpdateLoggerMQ::ApplyUpdateLog |
( |
DBM * |
dbm, |
|
|
std::string_view |
message, |
|
|
int32_t |
server_id = INT32MIN+1 , |
|
|
int32_t |
dbm_index = INT32MIN+1 |
|
) |
| |
|
static |
Applys the operation in an update log to a database.
- Parameters
-
dbm | The DBM object of the database. |
message | The update log message. |
server_id | The server ID to focus on. A negative applies a filter which ignores the message if the server ID mathces the absolute value. Zero or a positive applies a filter which adopts the message if the server ID matches the value. |
dbm_index | The DBM index to focus on. A negative applies a filter which ignores the message if the DBM index mathces the absolute value. Zero or a positive applies a filter which adopts the message if the DBM index matches the value. |
- Returns
- The result status. If the log is ignored due to the filter, INFEASIBLE_ERROR is returned.
◆ ApplyUpdateLogFromFiles()
static Status tkrzw::DBMUpdateLoggerMQ::ApplyUpdateLogFromFiles |
( |
DBM * |
dbm, |
|
|
const std::string & |
prefix, |
|
|
double |
min_timestamp = 0 , |
|
|
int32_t |
server_id = INT32MIN+1 , |
|
|
int32_t |
dbm_index = INT32MIN+1 |
|
) |
| |
|
static |
Applys the operations in the message queue files.
- Parameters
-
dbm | The DBM object of the database. |
prefix | The prefix for the message queue file names. |
min_timestamp | The minimum timestamp in milliseconds of messages to read. |
server_id | The server ID to focus on. A negative applies a filter which ignores the message if the server ID mathces the absolute value. Zero or a positive applies a filter which adopts the message if the server ID matches the value. |
dbm_index | The DBM index to focus on. A negative applies a filter which ignores the message if the DBM index mathces the absolute value. Zero or a positive applies a filter which adopts the message if the DBM index matches the value. |
- Returns
- The result status.