1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2009 Sun Microsystems
8
* Jay Pipes <joinfu@sun.com>
10
* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this program; if not, write to the Free Software
22
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
* Defines the API of a simple index for the transaction log
31
#ifndef PLUGIN_TRANSACTION_LOG_TRANSACTION_LOG_INDEX_H
32
#define PLUGIN_TRANSACTION_LOG_TRANSACTION_LOG_INDEX_H
34
#include "transaction_log.h"
35
#include "transaction_log_entry.h"
40
namespace drizzled { namespace message {class Transaction;}}
42
class TransactionLogIndex
45
explicit TransactionLogIndex(TransactionLog &in_log);
46
~TransactionLogIndex();
48
* Returns the minimum end timestamp of a transaction
49
* in the transaction log.
51
uint64_t getMinEndTimestamp() const;
53
* Returns the maximum end timestamp of a transaction
54
* in the transaction log.
56
uint64_t getMaxEndTimestamp() const;
58
* Returns the minimum transaction ID of a transaction
59
* in the transaction log.
61
uint64_t getMinTransactionId() const;
63
* Returns the maximum transaction ID of a transaction
64
* in the transaction log.
66
uint64_t getMaxTransactionId() const;
68
* Returns the total number of entries in the transaction log
70
uint64_t getNumLogEntries() const;
72
* Returns the total number of transaction entries in the transaction log
74
uint64_t getNumTransactionEntries() const;
76
* Returns whether the index encountered an
77
* error on its last action.
79
bool hasError() const;
81
* Returns the current error message
83
const std::string &getErrorMessage() const;
85
* Returns a reference to the index's collection
86
* of log entry objects
88
TransactionLog::Entries &getEntries();
90
* Returns a reference to the index's collection
91
* of transaction entry objects
93
TransactionLog::TransactionEntries &getTransactionEntries();
95
* Adds a new entry to the index of type Transaction message.
97
* @param[in] The transaction log entry
98
* @param[in] The transaction message
99
* @param[in] The checksum for the transaction message bytes
101
void addEntry(const TransactionLogEntry &entry,
102
const drizzled::message::Transaction &transaction,
105
/* Don't allows these */
106
TransactionLogIndex();
107
TransactionLogIndex(const TransactionLogIndex &other);
108
TransactionLogIndex &operator=(const TransactionLogIndex &other);
110
* Helper function to open/create the index from
111
* the transaction log.
115
* Clears the internal error state
119
TransactionLog &log; ///< The transaction log instance
120
int log_file; ///< File descriptor for the transaction log file
121
int index_file; ///< File descriptor for the transaction log on-disk index file
122
const std::string index_file_path; ///< Filename of the on-disk transaction log index
123
bool has_error; ///< Index is in error mode?
124
std::string error_message; ///< Current error message
126
uint64_t min_end_timestamp; ///< Minimum end timestamp in log
127
uint64_t max_end_timestamp; ///< Maximim end timestamp in log
128
uint64_t min_transaction_id; ///< Minimum transaction ID in log
129
uint64_t max_transaction_id; ///< Maximum transaction ID in log
130
uint64_t num_log_entries; ///< Total number of log entries in log
131
uint64_t num_transaction_entries; ///< Total number of transaction log entries in log
133
TransactionLog::Entries entries; ///< Collection of information about the entries in the log
134
TransactionLog::TransactionEntries transaction_entries; ///<
136
pthread_mutex_t index_lock; ///< The global index lock
139
#endif /* PLUGIN_TRANSACTION_LOG_TRANSACTION_LOG_INDEX_H */