~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/transaction_log/transaction_log.h

Adds a vector of write buffers to the transaction log applier
object.  This eliminates the calls to malloc() for writing
most transaction log entries (the only calls to malloc() will
be when an existing write buffer is not large enough).  

There is a configuration setting now for the number of write
buffers to create on startup.  The slot algorithm is a simple
modulo on the session ID.

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
  /**
70
66
  static const uint32_t SYNC_METHOD_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_sync_method,
 
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);
181
207
  std::string error_message; ///< Current error message
182
208
  uint32_t sync_method; ///< Determines behaviour of syncing log file
183
209
  time_t last_sync_time; ///< Last time the log file was synced (only set in SYNC_METHOD_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 */