~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/transaction_log/module.cc

  • Committer: Mark Atwood
  • Date: 2011-08-11 03:05:03 UTC
  • mfrom: (2385.1.12 refactor4)
  • Revision ID: me@mark.atwood.name-20110811030503-rp9xjihc5x3y0x4q
mergeĀ lp:~olafvdspek/drizzle/refactor4

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 * registration.
31
31
 */
32
32
 
33
 
#include "config.h"
 
33
#include <config.h>
34
34
 
35
35
#include "transaction_log.h"
36
36
#include "transaction_log_applier.h"
38
38
#include "data_dictionary_schema.h"
39
39
#include "print_transaction_message.h"
40
40
#include "hexdump_transaction_message.h"
41
 
#include "background_worker.h"
42
41
 
43
42
#include <errno.h>
44
43
 
47
46
#include <drizzled/gettext.h>
48
47
#include <boost/program_options.hpp>
49
48
#include <drizzled/module/option_map.h>
 
49
#include <drizzled/plugin/function.h>
50
50
 
51
51
namespace po= boost::program_options;
52
52
using namespace std;
160
160
  if (sysvar_transaction_log_enabled)
161
161
  {
162
162
  
163
 
    transaction_log= new (nothrow) TransactionLog(sysvar_transaction_log_file,
 
163
    transaction_log= new TransactionLog(sysvar_transaction_log_file,
164
164
                                                  static_cast<int>(sysvar_transaction_log_flush_frequency),
165
165
                                                  sysvar_transaction_log_checksum_enabled);
166
166
 
181
181
    }
182
182
 
183
183
    /* Create and initialize the transaction log index */
184
 
    transaction_log_index= new (nothrow) TransactionLogIndex(*transaction_log);
185
 
    if (transaction_log_index == NULL)
186
 
    {
187
 
      sql_perror(_("Failed to allocate the TransactionLogIndex instance"), sysvar_transaction_log_file);
188
 
      return 1;
189
 
    }
190
 
    else
191
 
    {
 
184
    transaction_log_index= new TransactionLogIndex(*transaction_log);
192
185
      /* Check to see if the index was not created properly */
193
186
      if (transaction_log_index->hasError())
194
187
      {
196
189
                      transaction_log_index->getErrorMessage().c_str());
197
190
        return 1;
198
191
      }
199
 
    }
200
192
 
201
193
    /* Create the applier plugin and register it */
202
 
    transaction_log_applier= new (nothrow) TransactionLogApplier("transaction_log_applier",
 
194
    transaction_log_applier= new TransactionLogApplier("transaction_log_applier",
203
195
                                                                 transaction_log, 
204
196
                                                                 transaction_log_index, 
205
197
                                                                 static_cast<uint32_t>(sysvar_transaction_log_num_write_buffers));
206
 
    if (transaction_log_applier == NULL)
207
 
    {
208
 
      sql_perror(_("Failed to allocate the TransactionLogApplier instance"), sysvar_transaction_log_file);
209
 
      return 1;
210
 
    }
211
198
    context.add(transaction_log_applier);
212
 
    ReplicationServices &replication_services= ReplicationServices::singleton();
213
 
    replication_services.attachApplier(transaction_log_applier,
214
 
                                       sysvar_transaction_log_use_replicator);
 
199
    ReplicationServices::attachApplier(transaction_log_applier, sysvar_transaction_log_use_replicator);
215
200
 
216
201
    /* Setup DATA_DICTIONARY views */
217
202
 
218
 
    transaction_log_tool= new (nothrow) TransactionLogTool;
 
203
    transaction_log_tool= new TransactionLogTool;
219
204
    context.add(transaction_log_tool);
220
 
    transaction_log_entries_tool= new (nothrow) TransactionLogEntriesTool;
 
205
    transaction_log_entries_tool= new TransactionLogEntriesTool;
221
206
    context.add(transaction_log_entries_tool);
222
 
    transaction_log_transactions_tool= new (nothrow) TransactionLogTransactionsTool;
 
207
    transaction_log_transactions_tool= new TransactionLogTransactionsTool;
223
208
    context.add(transaction_log_transactions_tool);
224
209
 
225
210
    /* Setup the module's UDFs */
230
215
    hexdump_transaction_message_func_factory=
231
216
      new plugin::Create_function<HexdumpTransactionMessageFunction>("hexdump_transaction_message");
232
217
    context.add(hexdump_transaction_message_func_factory);
233
 
 
234
 
    /* 
235
 
     * Setup the background worker thread which maintains
236
 
     * summary information about the transaction log.
237
 
     */
238
 
    if (initTransactionLogBackgroundWorker())
239
 
      return 1; /* Error message output handled in function above */
240
218
  }
241
219
  return 0;
242
220
}