~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/transaction_log/transaction_log.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-10-02 14:17:48 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (2.1.17 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20101002141748-m6vbfbfjhrw1153e
Tags: 2010.09.1802-1
* New upstream release.
* Removed pid-file argument hack.
* Updated GPL-2 address to be new address.
* Directly copy in drizzledump.1 since debian doesn't have sphinx 1.0 yet.
* Link to jquery from libjs-jquery. Add it as a depend.
* Add drizzled.8 symlink to the install files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
class TransactionLog
50
50
{
51
51
public:
52
 
  static const uint32_t HEADER_TRAILER_BYTES= sizeof(uint32_t) + /* 4-byte msg type header */
53
 
                                              sizeof(uint32_t) + /* 4-byte length header */
54
 
                                              sizeof(uint32_t); /* 4 byte checksum trailer */
55
 
 
56
52
  typedef std::vector<TransactionLogEntry> Entries;
57
53
  typedef std::vector<TransactionLogTransactionEntry> TransactionEntries;
58
54
  /**
65
61
    ONLINE,
66
62
    WRITING
67
63
  };
68
 
  static const uint32_t SYNC_METHOD_OS= 0; ///< Rely on operating system to sync log file
69
 
  static const uint32_t SYNC_METHOD_EVERY_WRITE= 1; //< Sync on every write to the log file
70
 
  static const uint32_t SYNC_METHOD_EVERY_SECOND= 2; ///< Sync no more than once a second
 
64
  static const uint32_t FLUSH_FREQUENCY_OS= 0; ///< Rely on operating system to sync log file
 
65
  static const uint32_t FLUSH_FREQUENCY_EVERY_WRITE= 1; //< Sync on every write to the log file
 
66
  static const uint32_t FLUSH_FREQUENCY_EVERY_SECOND= 2; ///< Sync no more than once a second
71
67
public:
72
68
  TransactionLog(const std::string in_log_file_path,
73
 
                 uint32_t in_sync_method);
 
69
                 uint32_t in_flush_frequency,
 
70
                 bool in_do_checksum);
74
71
 
75
72
  /** Destructor */
76
73
  ~TransactionLog();
102
99
  }
103
100
 
104
101
  /**
 
102
   * Static helper method which returns the transaction
 
103
   * log entry size in bytes of a given transaction
 
104
   * message.
 
105
   *
 
106
   * @param[in] Transaction message
 
107
   */
 
108
  static size_t getLogEntrySize(const drizzled::message::Transaction &trx);
 
109
 
 
110
  /**
 
111
   * Method which packs into a raw byte buffer
 
112
   * a transaction log entry.  Supplied buffer should
 
113
   * be of adequate size.
 
114
   *
 
115
   * Returns a pointer to the start of the original
 
116
   * buffer.
 
117
   *
 
118
   * @param[in]   Transaction message to pack
 
119
   * @param[in]   Raw byte buffer
 
120
   * @param[out]  Pointer to storage for checksum of message
 
121
   */
 
122
  uint8_t *packTransactionIntoLogEntry(const drizzled::message::Transaction &trx,
 
123
                                       uint8_t *buffer,
 
124
                                       uint32_t *checksum_out);
 
125
 
 
126
  /**
105
127
   * Writes a chunk of data to the log file of a specified
106
128
   * length and returns the offset at which the chunk of
107
129
   * data was written.
153
175
   */
154
176
  const std::string &getErrorMessage() const;
155
177
private:
 
178
  static const uint32_t HEADER_TRAILER_BYTES= sizeof(uint32_t) + /* 4-byte msg type header */
 
179
                                              sizeof(uint32_t) + /* 4-byte length header */
 
180
                                              sizeof(uint32_t); /* 4 byte checksum trailer */
 
181
 
156
182
  /* Don't allows these */
157
183
  TransactionLog();
158
184
  TransactionLog(const TransactionLog &other);
163
189
  void clearError();
164
190
  /**
165
191
   * Helper method which synchronizes/flushes the transaction log file
166
 
   * according to the transaction_log_sync_method system variable
 
192
   * according to the transaction_log_flush_frequency system variable
167
193
   *
168
194
   * @retval
169
195
   *   0 == Success
179
205
  drizzled::atomic<off_t> log_offset; ///< Offset in log file where log will write next command
180
206
  bool has_error; ///< Is the log in error?
181
207
  std::string error_message; ///< Current error message
182
 
  uint32_t sync_method; ///< Determines behaviour of syncing log file
183
 
  time_t last_sync_time; ///< Last time the log file was synced (only set in SYNC_METHOD_EVERY_SECOND)
 
208
  uint32_t flush_frequency; ///< Determines behaviour of syncing log file
 
209
  time_t last_sync_time; ///< Last time the log file was synced (only set in FLUSH_FREQUENCY_EVERY_SECOND)
 
210
  bool do_checksum; ///< Do a CRC32 checksum when writing Transaction message to log?
184
211
};
185
212
 
186
213
#endif /* PLUGIN_TRANSACTION_LOG_TRANSACTION_LOG_H */