~fallenpegasus/drizzle/work-foo

« back to all changes in this revision

Viewing changes to plugin/transaction_log/transaction_log_entry.h

  • Committer: Continuous Integration
  • Date: 2012-03-04 12:46:01 UTC
  • mfrom: (2516.2.1 workspace)
  • Revision ID: ci@drizzle.org-20120304124601-nqj8znhwmhhbsbha
Merge staging tree to trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008-2009 Sun Microsystems, Inc.
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 a simple structure representing a transaction log entry.
29
 
 */
30
 
 
31
 
#pragma once
32
 
 
33
 
#include <drizzled/replication_services.h>
34
 
 
35
 
#include <string>
36
 
 
37
 
/**
38
 
 * Represents a single entry in the transaction log.
39
 
 */
40
 
class TransactionLogEntry
41
 
{
42
 
public:
43
 
  TransactionLogEntry(drizzled::ReplicationServices::MessageType in_type,
44
 
                      off_t in_offset,
45
 
                      size_t length);
46
 
  ~TransactionLogEntry();
47
 
  /**
48
 
   * Returns a string representation of the entry type
49
 
   */
50
 
  const char *getTypeAsString() const;
51
 
  /**
52
 
   * Returns the entry's offset in the log
53
 
   */
54
 
  off_t getOffset() const;
55
 
  /**
56
 
   * Returns the length of the entry in bytes
57
 
   */
58
 
  size_t getLengthInBytes() const;
59
 
private:
60
 
  enum drizzled::ReplicationServices::MessageType type; ///< The type of the entry
61
 
  off_t offset; ///< Offset into the log file
62
 
  size_t length; ///< Length in bytes of the entry
63
 
};
64
 
 
65
 
class TransactionLogTransactionEntry
66
 
{
67
 
public:
68
 
  TransactionLogTransactionEntry(off_t in_offset,
69
 
                                 const drizzled::message::Transaction &transaction,
70
 
                                 uint32_t in_checksum);
71
 
  ~TransactionLogTransactionEntry();
72
 
  /**
73
 
   * Returns the entry's offset in the log
74
 
   */
75
 
  off_t getOffset() const;
76
 
  /**
77
 
   * Returns the transaction's server ID
78
 
   */
79
 
  uint32_t getServerId() const;
80
 
  /**
81
 
   * Returns the transaction's start timestamp
82
 
   */
83
 
  uint64_t getStartTimestamp() const;
84
 
  /**
85
 
   * Returns the transaction's end timestamp
86
 
   */
87
 
  uint64_t getEndTimestamp() const;
88
 
  /**
89
 
   * Returns the transaction's ID
90
 
   */
91
 
  uint64_t getTransactionId() const;
92
 
  /**
93
 
   * Returns the number of statements in the transaction
94
 
   */
95
 
  uint64_t getNumStatements() const;
96
 
  /**
97
 
   * Returns the checksum for the transaction message bytes
98
 
   */
99
 
  uint32_t getChecksum() const;
100
 
private:
101
 
  off_t offset; ///< Offset into the log file
102
 
  uint32_t server_id; ///< The server ID that this transaction came from
103
 
  uint64_t transaction_id; ///< The transaction's ID
104
 
  uint64_t start_timestamp; ///< The transaction's start timestamp
105
 
  uint64_t end_timestamp; ///< The transaction's end timestamp
106
 
  uint32_t num_statements; ///< Number of Statements in the transaction
107
 
  uint32_t checksum; ///< Checksum of the transaction message bytes
108
 
};
109