76
80
* TransactionLog::SYNC_METHOD_EVERY_SECOND == 2 ... sync at most once a second
78
82
static uint32_t sysvar_transaction_log_sync_method= 0;
84
* Transaction Log plugin system variable - Number of slots to create
85
* for managing write buffers
87
static uint32_t sysvar_transaction_log_num_write_buffers= 8;
89
* Transaction Log plugin system variable - The name of the replicator plugin
90
* to pair the transaction log's applier with. Defaults to "default"
92
static char *sysvar_transaction_log_use_replicator= NULL;
93
static const char DEFAULT_USE_REPLICATOR[]= "default";
80
95
/** DATA_DICTIONARY views */
81
96
static TransactionLogTool *transaction_log_tool;
93
108
extern plugin::Create_function<PrintTransactionMessageFunction> *print_transaction_message_func_factory;
94
109
extern plugin::Create_function<HexdumpTransactionMessageFunction> *hexdump_transaction_message_func_factory;
96
static int init(drizzled::plugin::Registry ®istry)
111
static int init(drizzled::plugin::Context &context)
98
113
/* Create and initialize the transaction log itself */
99
114
if (sysvar_transaction_log_enabled)
101
116
transaction_log= new (nothrow) TransactionLog(string(sysvar_transaction_log_file),
102
sysvar_transaction_log_sync_method);
117
sysvar_transaction_log_sync_method,
118
sysvar_transaction_log_checksum_enabled);
104
120
if (transaction_log == NULL)
137
/* Create and initialize the transaction log index */
138
transaction_log_index= new (nothrow) TransactionLogIndex(*transaction_log);
139
if (transaction_log_index == NULL)
141
errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate the TransactionLogIndex instance. Got error: %s\n"),
147
/* Check to see if the index was not created properly */
148
if (transaction_log_index->hasError())
150
errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to initialize the Transaction Log Index. Got error: %s\n"),
151
transaction_log_index->getErrorMessage().c_str());
120
156
/* Create the applier plugin and register it */
121
157
transaction_log_applier= new (nothrow) TransactionLogApplier("transaction_log_applier",
123
sysvar_transaction_log_checksum_enabled);
159
transaction_log_index,
160
sysvar_transaction_log_num_write_buffers);
124
161
if (transaction_log_applier == NULL)
126
163
errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate the TransactionLogApplier instance. Got error: %s\n"),
127
164
strerror(errno));
130
registry.add(transaction_log_applier);
167
context.add(transaction_log_applier);
168
ReplicationServices &replication_services= ReplicationServices::singleton();
169
string replicator_name(sysvar_transaction_log_use_replicator);
170
replication_services.attachApplier(transaction_log_applier, replicator_name);
132
172
/* Setup DATA_DICTIONARY views */
134
174
transaction_log_tool= new (nothrow) TransactionLogTool;
135
registry.add(transaction_log_tool);
175
context.add(transaction_log_tool);
136
176
transaction_log_entries_tool= new (nothrow) TransactionLogEntriesTool;
137
registry.add(transaction_log_entries_tool);
177
context.add(transaction_log_entries_tool);
138
178
transaction_log_transactions_tool= new (nothrow) TransactionLogTransactionsTool;
139
registry.add(transaction_log_transactions_tool);
179
context.add(transaction_log_transactions_tool);
141
181
/* Setup the module's UDFs */
142
182
print_transaction_message_func_factory=
143
183
new plugin::Create_function<PrintTransactionMessageFunction>("print_transaction_message");
144
registry.add(print_transaction_message_func_factory);
184
context.add(print_transaction_message_func_factory);
146
186
hexdump_transaction_message_func_factory=
147
187
new plugin::Create_function<HexdumpTransactionMessageFunction>("hexdump_transaction_message");
148
registry.add(hexdump_transaction_message_func_factory);
150
/* Create and initialize the transaction log index */
151
transaction_log_index= new (nothrow) TransactionLogIndex(*transaction_log);
152
if (transaction_log_index == NULL)
154
errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to allocate the TransactionLogIndex instance. Got error: %s\n"),
160
/* Check to see if the index was not created properly */
161
if (transaction_log_index->hasError())
163
errmsg_printf(ERRMSG_LVL_ERROR, _("Failed to initialize the Transaction Log Index. Got error: %s\n"),
164
transaction_log_index->getErrorMessage().c_str());
188
context.add(hexdump_transaction_message_func_factory);
170
191
* Setup the background worker thread which maintains
179
static int deinit(drizzled::plugin::Registry ®istry)
181
/* Cleanup the transaction log itself */
184
registry.remove(transaction_log_applier);
185
delete transaction_log;
186
delete transaction_log_index;
188
/* Cleanup the DATA_DICTIONARY views */
189
registry.remove(transaction_log_tool);
190
delete transaction_log_tool;
191
registry.remove(transaction_log_entries_tool);
192
delete transaction_log_entries_tool;
193
registry.remove(transaction_log_transactions_tool);
194
delete transaction_log_transactions_tool;
196
/* Cleanup module UDFs */
197
registry.remove(print_transaction_message_func_factory);
198
delete print_transaction_message_func_factory;
199
registry.remove(hexdump_transaction_message_func_factory);
200
delete hexdump_transaction_message_func_factory;
206
201
static void set_truncate_debug(Session *,
207
202
drizzle_sys_var *,
246
241
NULL, /* update func*/
247
242
DEFAULT_LOG_FILE_PATH /* default */);
244
static DRIZZLE_SYSVAR_STR(use_replicator,
245
sysvar_transaction_log_use_replicator,
247
N_("Name of the replicator plugin to use (default='default_replicator')"),
248
NULL, /* check func */
249
NULL, /* update func*/
250
DEFAULT_USE_REPLICATOR /* default */);
249
252
static DRIZZLE_SYSVAR_BOOL(enable_checksum,
250
253
sysvar_transaction_log_checksum_enabled,
251
254
PLUGIN_VAR_NOCMDARG,
273
static DRIZZLE_SYSVAR_UINT(num_write_buffers,
274
sysvar_transaction_log_num_write_buffers,
276
N_("Number of slots for in-memory write buffers (default=8)."),
277
NULL, /* check func */
278
NULL, /* update func */
270
284
static drizzle_sys_var* sys_variables[]= {
271
285
DRIZZLE_SYSVAR(enable),
272
286
DRIZZLE_SYSVAR(truncate_debug),
273
DRIZZLE_SYSVAR(log_file),
287
DRIZZLE_SYSVAR(file),
274
288
DRIZZLE_SYSVAR(enable_checksum),
275
289
DRIZZLE_SYSVAR(sync_method),
290
DRIZZLE_SYSVAR(num_write_buffers),
291
DRIZZLE_SYSVAR(use_replicator),
279
DRIZZLE_PLUGIN(init, deinit, sys_variables);
295
DRIZZLE_PLUGIN(init, sys_variables);