~drizzle-trunk/drizzle/development

1143.3.4 by Jay Pipes
Adds INFORMATION_SCHEMA views for the transaction log:
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2009 Sun Microsystems
5
 *
6
 *  Authors:
7
 *
8
 *  Jay Pipes <joinfu@sun.com>
9
 *
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.
14
 *
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.
19
 *
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
23
 */
24
25
/**
26
 * @file
27
 *
28
 * Defines the implementation of a transaction log entry POD class
29
 */
30
1241.9.36 by Monty Taylor
ZOMG. I deleted drizzled/server_includes.h.
31
#include "config.h"
1143.3.4 by Jay Pipes
Adds INFORMATION_SCHEMA views for the transaction log:
32
33
#include "transaction_log_entry.h"
34
1336.2.2 by Jay Pipes
NO CODE CHANGES - Simply moves pieces of ReplicationServices to TransactionServices. Preparation for making the ReplicationServices component only responsible for communication between replicators, appliers, publishers, and subscribers.
35
#include <drizzled/message/transaction.pb.h>
36
1143.3.4 by Jay Pipes
Adds INFORMATION_SCHEMA views for the transaction log:
37
#include <string>
38
#include <map>
39
40
using namespace std;
41
using namespace drizzled;
42
43
static const char *entry_type_names[]= 
44
{
45
  "UNKNOWN",
46
  "TRANSACTION",
47
  "RAW BLOB"
48
};
49
50
TransactionLogEntry::TransactionLogEntry(enum ReplicationServices::MessageType in_type,
51
                                         off_t in_offset,
52
                                         size_t in_length) :
53
  type(in_type),
54
  offset(in_offset),
55
  length(in_length)
56
{}
57
58
TransactionLogEntry::~TransactionLogEntry()
59
{}
60
61
const char *TransactionLogEntry::getTypeAsString() const
62
{
63
  return entry_type_names[type];
64
}
65
66
off_t TransactionLogEntry::getOffset() const
67
{
68
  return offset;
69
}
70
71
size_t TransactionLogEntry::getLengthInBytes() const
72
{
73
  return length;
74
}
75
76
TransactionLogTransactionEntry::TransactionLogTransactionEntry(off_t in_offset,
77
                                                               const message::Transaction &transaction,
78
                                                               uint32_t in_checksum) :
79
  offset(in_offset),
80
  server_id(transaction.transaction_context().server_id()),
81
  transaction_id(transaction.transaction_context().transaction_id()),
82
  start_timestamp(transaction.transaction_context().start_timestamp()),
83
  end_timestamp(transaction.transaction_context().end_timestamp()),
84
  num_statements(transaction.statement_size()),
85
  checksum(in_checksum)
86
{
87
}
88
89
TransactionLogTransactionEntry::~TransactionLogTransactionEntry()
90
{}
91
92
off_t TransactionLogTransactionEntry::getOffset() const
93
{
94
  return offset;
95
}
96
97
uint64_t TransactionLogTransactionEntry::getTransactionId() const
98
{
99
  return transaction_id;
100
}
101
102
uint32_t TransactionLogTransactionEntry::getServerId() const
103
{
104
  return server_id;
105
}
106
107
uint64_t TransactionLogTransactionEntry::getStartTimestamp() const
108
{
109
  return start_timestamp;
110
}
111
112
uint64_t TransactionLogTransactionEntry::getEndTimestamp() const
113
{
114
  return end_timestamp;
115
}
116
117
uint64_t TransactionLogTransactionEntry::getNumStatements() const
118
{
119
  return num_statements;
120
}
121
122
uint32_t TransactionLogTransactionEntry::getChecksum() const
123
{
124
  return checksum;
125
}