~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/command_log/command_log.h

  • Committer: Brian Aker
  • Date: 2009-09-21 23:40:18 UTC
  • mfrom: (1039.5.63 replication)
  • Revision ID: brian@gaz-20090921234018-gd9kqdyigwxtik9z
Merge Jay

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 *
29
29
 * @details
30
30
 *
31
 
 * The CommandLog applies events it receives from the TransactionServices
 
31
 * The CommandLog applies events it receives from the ReplicationServices
32
32
 * server component to a simple log file on disk.
33
33
 * 
34
 
 * Events are received in no guaranteed order and the command log
 
34
 * Commands are received in no guaranteed order and the command log
35
35
 * is in charge of writing these events to the log as they are received.
36
36
 */
37
37
 
38
 
#ifndef DRIZZLE_PLUGIN_command_log_H
39
 
#define DRIZZLE_PLUGIN_command_log_H
 
38
#ifndef DRIZZLE_PLUGIN_COMMAND_LOG_H
 
39
#define DRIZZLE_PLUGIN_COMMAND_LOG_H
40
40
 
41
41
#include <drizzled/server_includes.h>
42
42
#include <drizzled/atomics.h>
43
 
#include <drizzled/plugin/replicator.h>
44
 
#include <drizzled/plugin/applier.h>
 
43
#include <drizzled/replication_services.h>
 
44
#include <drizzled/plugin/command_replicator.h>
 
45
#include <drizzled/plugin/command_applier.h>
45
46
 
46
47
#include <vector>
47
48
#include <string>
48
49
 
49
 
class CommandLog: public drizzled::plugin::Applier 
 
50
class CommandLog: public drizzled::plugin::CommandApplier 
50
51
{
51
52
public:
52
53
  enum status
61
62
  enum status state; /**< The state the log is in */
62
63
  drizzled::atomic<bool> is_enabled; /**< Internal toggle. Atomic to support online toggling of command log... */
63
64
  drizzled::atomic<bool> is_active; /**< Internal toggle. If true, log was initialized properly... */
 
65
  drizzled::atomic<bool> do_checksum; ///< Do a CRC32 checksum when writing Command message to log?
64
66
  const char *log_file_path; /**< Full path to the log file */
65
67
  drizzled::atomic<off_t> log_offset; /**< Offset in log file where log will write next command */
66
68
public:
67
 
  CommandLog(const char *in_log_file_path);
 
69
  CommandLog(const char *in_log_file_path, bool in_do_checksum);
68
70
 
69
71
  /** Destructor */
70
72
  ~CommandLog();
84
86
   *
85
87
   * @param Command message to be replicated
86
88
   */
87
 
  void apply(drizzled::message::Command *to_apply);
 
89
  void apply(const drizzled::message::Command &to_apply);
88
90
  
89
91
  /** 
90
92
   * Returns whether the command log is active.
128
130
   * set to anything other than false, this is called.
129
131
   */
130
132
  void truncate();
 
133
 
 
134
  /**
 
135
   * Takes a global transaction ID and a reference to a string to fill
 
136
   * with the name of the log file which contains the command with the 
 
137
   * transaction ID.  If the transaction ID is contained in a log file, 
 
138
   * the function returns true, false otherwise.
 
139
   *
 
140
   * @param[in] Global transaction ID to search on
 
141
   * @param[inout] String to fill with name of logfile containing command with
 
142
   *               the needed transaction ID
 
143
   *
 
144
   * @retval
 
145
   *  true if found
 
146
   * @retval
 
147
   *  false otherwise
 
148
   */
 
149
  bool findLogFilenameContainingTransactionId(const drizzled::ReplicationServices::GlobalTransactionId &to_find,
 
150
                                              std::string &out_filename) const;
131
151
};
132
152
 
133
 
#endif /* DRIZZLE_PLUGIN_command_log_H */
 
153
#endif /* DRIZZLE_PLUGIN_COMMAND_LOG_H */