4
4
* Copyright (C) 2008-2009 Sun Microsystems
8
* Jay Pipes <joinfu@sun.com>
6
10
* This program is free software; you can redistribute it and/or modify
7
11
* it under the terms of the GNU General Public License as published by
8
12
* the Free Software Foundation; either version 2 of the License, or
24
* Defines the API of the default command log.
28
* Defines the API of the default transaction log.
26
30
* @see drizzled/plugin/replicator.h
27
31
* @see drizzled/plugin/applier.h
31
* The CommandLog applies events it receives from the ReplicationServices
35
* The TransactionLog applies events it receives from the ReplicationServices
32
36
* server component to a simple log file on disk.
34
* Commands are received in no guaranteed order and the command log
38
* Transactions are received in no guaranteed order and the command log
35
39
* is in charge of writing these events to the log as they are received.
38
#ifndef PLUGIN_COMMAND_LOG_COMMAND_LOG_H
39
#define PLUGIN_COMMAND_LOG_COMMAND_LOG_H
42
#ifndef PLUGIN_TRANSACTION_LOG_TRANSACTION_LOG_H
43
#define PLUGIN_TRANSACTION_LOG_TRANSACTION_LOG_H
41
45
#include <drizzled/atomics.h>
42
46
#include <drizzled/replication_services.h>
43
#include <drizzled/plugin/command_replicator.h>
44
#include <drizzled/plugin/command_applier.h>
47
#include <drizzled/plugin/transaction_replicator.h>
48
#include <drizzled/plugin/transaction_applier.h>
49
class CommandLog: public drizzled::plugin::CommandApplier
53
class TransactionLog: public drizzled::plugin::TransactionApplier
56
static const uint32_t HEADER_TRAILER_BYTES= sizeof(uint32_t) + /* 4-byte msg type header */
57
sizeof(uint32_t) + /* 4-byte length header */
58
sizeof(uint32_t); /* 4 byte checksum trailer */
61
* The state the log is in
55
66
OFFLINE, /* Default state, uninited. */
60
71
int log_file; /**< Handle for our log file */
61
enum status state; /**< The state the log is in */
62
drizzled::atomic<bool> do_checksum; ///< Do a CRC32 checksum when writing Command message to log?
72
enum Status state; /**< The state the log is in */
73
drizzled::atomic<bool> do_checksum; ///< Do a CRC32 checksum when writing Transaction message to log?
63
74
const char *log_file_path; /**< Full path to the log file */
64
75
drizzled::atomic<off_t> log_offset; /**< Offset in log file where log will write next command */
66
CommandLog(std::string name_arg,
67
const char *in_log_file_path, bool in_do_checksum);
77
TransactionLog(std::string name_arg,
78
const char *in_log_file_path,
73
* Applies a Command to the serial log
85
* Applies a Transaction to the serial log
82
94
* the supplied message to their own controlled memory storage
85
* @param Command message to be replicated
97
* @param Transaction message to be replicated
87
void apply(const drizzled::message::Command &to_apply);
99
void apply(const drizzled::message::Transaction &to_apply);
90
102
* Returns the state that the log is in
92
inline enum status getState()
104
inline enum Status getState()