Tkrzw-RPC
Public Member Functions | Public Attributes | Friends | List of all members
tkrzw::RemoteDBM::Replicator Class Reference

Reader for update logs for asynchronous replicatoin. More...

#include <tkrzw_dbm_remote.h>

Public Member Functions

 ~Replicator ()
 Destructor. More...
 
 Replicator (const Replicator &rhs)=delete
 Copy and assignment are disabled. More...
 
Replicatoroperator= (const Replicator &rhs)=delete
 
void Cancel ()
 Cancels the current operation. More...
 
int32_t GetMasterServerID ()
 Get the server ID of the master server. More...
 
Status Start (int64_t min_timestamp, int32_t server_id=0, double wait_time=-1)
 Starts replication. More...
 
Status Read (int64_t *timestamp, ReplicateLog *op)
 Reads the next update log. More...
 
 Replicator (RemoteDBMImpl *dbm_impl)
 Constructor. More...
 

Public Attributes

RemoteDBMReplicatorImpl * impl_
 Pointer to the actual implementation. More...
 

Friends

class tkrzw::RemoteDBM
 

Detailed Description

Reader for update logs for asynchronous replicatoin.

An instance of this class dominates a thread on the server so you should destroy when it is no longer in use.

Constructor & Destructor Documentation

◆ ~Replicator()

tkrzw::RemoteDBM::Replicator::~Replicator ( )

Destructor.

◆ Replicator() [1/2]

tkrzw::RemoteDBM::Replicator::Replicator ( const Replicator rhs)
explicitdelete

Copy and assignment are disabled.

◆ Replicator() [2/2]

tkrzw::RemoteDBM::Replicator::Replicator ( RemoteDBMImpl *  dbm_impl)
explicit

Constructor.

Parameters
dbm_implThe database implementation object.

Member Function Documentation

◆ Cancel()

void tkrzw::RemoteDBM::Replicator::Cancel ( )

Cancels the current operation.

This is called by another thread than the thread doing the operation.

◆ GetMasterServerID()

int32_t tkrzw::RemoteDBM::Replicator::GetMasterServerID ( )

Get the server ID of the master server.

Returns
The server ID of the master server or -1 on failure.

Ths can be called only after the Start method returns success.

◆ Start()

Status tkrzw::RemoteDBM::Replicator::Start ( int64_t  min_timestamp,
int32_t  server_id = 0,
double  wait_time = -1 
)

Starts replication.

Parameters
min_timestampThe minimum timestamp in milliseconds of messages to read.
server_idThe server ID of the process. Logs with the same server ID are skipped to avoid infinite loop.
wait_timeThe time in seconds to wait for the next log. Zero means no wait. Negative means unlimited.
Returns
The result status.

◆ Read()

Status tkrzw::RemoteDBM::Replicator::Read ( int64_t *  timestamp,
ReplicateLog op 
)

Reads the next update log.

Parameters
timestampThe pointer to a variable to store the timestamp in milliseconds of the message. This is set if the result is SUCCESS or INFEASIBLE_ERROR.
opThe 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. If the wait time passes, INFEASIBLE_ERROR is returned. If the writer closes the file while waiting, CANCELED_ERROR is returned.

Member Data Documentation

◆ impl_

RemoteDBMReplicatorImpl* tkrzw::RemoteDBM::Replicator::impl_

Pointer to the actual implementation.