~drizzle-trunk/drizzle/development

1273.22.1 by Jay Pipes
Completes the blueprint for refactoring applier out of log descriptor.
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
5
 *  Copyright (c) 2010 Jay Pipes <jaypipes@gmail.com>
6
 *
7
 *  Authors:
8
 *
9
 *  Jay Pipes <jaypipes@gmail.com.com>
10
 *
11
 *  This program is free software; you can redistribute it and/or modify
12
 *  it under the terms of the GNU General Public License as published by
13
 *  the Free Software Foundation; either version 2 of the License, or
14
 *  (at your option) any later version.
15
 *
16
 *  This program is distributed in the hope that it will be useful,
17
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 *  GNU General Public License for more details.
20
 *
21
 *  You should have received a copy of the GNU General Public License
22
 *  along with this program; if not, write to the Free Software
23
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24
 */
25
26
/**
27
 * @file
28
 *
29
 * Defines the API of the transaction log applier.
30
 *
31
 * @see drizzled/plugin/replicator.h
32
 * @see drizzled/plugin/applier.h
33
 */
34
35
#ifndef PLUGIN_TRANSACTION_LOG_TRANSACTION_LOG_APPLIER_H
36
#define PLUGIN_TRANSACTION_LOG_TRANSACTION_LOG_APPLIER_H
37
38
#include <drizzled/replication_services.h>
39
#include <drizzled/plugin/transaction_applier.h>
40
41
#include "transaction_log_entry.h"
42
43
#include <vector>
44
#include <string>
45
1405.4.1 by Jay Pipes
Adds a vector of write buffers to the transaction log applier
46
namespace drizzled
47
{
48
  class Session;
49
}
50
1273.22.1 by Jay Pipes
Completes the blueprint for refactoring applier out of log descriptor.
51
class TransactionLog;
1455.5.1 by Jay Pipes
TransactionLogApplier now manages (frees) memory for TransactionLog and TransactionLogIndex
52
class TransactionLogIndex;
1405.4.1 by Jay Pipes
Adds a vector of write buffers to the transaction log applier
53
class WriteBuffer;
1273.22.1 by Jay Pipes
Completes the blueprint for refactoring applier out of log descriptor.
54
55
class TransactionLogApplier: public drizzled::plugin::TransactionApplier 
56
{
57
public:
58
  TransactionLogApplier(const std::string name_arg,
1452.1.2 by mordred
Made the TransactionLogApplier own the memory of the TransactionLog.
59
                        TransactionLog *in_transaction_log,
1455.5.1 by Jay Pipes
TransactionLogApplier now manages (frees) memory for TransactionLog and TransactionLogIndex
60
                        TransactionLogIndex *in_transaction_log_index,
1405.4.1 by Jay Pipes
Adds a vector of write buffers to the transaction log applier
61
                        uint32_t in_num_write_buffers);
1273.22.1 by Jay Pipes
Completes the blueprint for refactoring applier out of log descriptor.
62
63
  /** Destructor */
64
  ~TransactionLogApplier();
65
66
  /**
67
   * Applies a Transaction to the serial log
68
   *
69
   * @note
70
   *
71
   * It is important to note that memory allocation for the 
72
   * supplied pointer is not guaranteed after the completion 
73
   * of this function -- meaning the caller can dispose of the
74
   * supplied message.  Therefore, appliers which are
75
   * implementing an asynchronous replication system must copy
76
   * the supplied message to their own controlled memory storage
77
   * area.
78
   *
1405.3.3 by Jay Pipes
Adds Session reference to replication API
79
   * @param Session descriptor
1273.22.1 by Jay Pipes
Completes the blueprint for refactoring applier out of log descriptor.
80
   * @param Transaction message to be replicated
81
   */
1405.3.1 by Jay Pipes
Adapts the plugin::TransactionReplicator and plugin::TransactionApplier
82
  drizzled::plugin::ReplicationReturnCode
1405.3.7 by Jay Pipes
Change to non-const Session reference in replication API.
83
  apply(drizzled::Session &in_session,
1405.3.3 by Jay Pipes
Adds Session reference to replication API
84
        const drizzled::message::Transaction &to_apply);
1273.22.1 by Jay Pipes
Completes the blueprint for refactoring applier out of log descriptor.
85
private:
86
  /* Don't allows these */
87
  TransactionLogApplier();
88
  TransactionLogApplier(const TransactionLogApplier &other);
89
  TransactionLogApplier &operator=(const TransactionLogApplier &other);
1455.5.1 by Jay Pipes
TransactionLogApplier now manages (frees) memory for TransactionLog and TransactionLogIndex
90
  /** 
91
   * This Applier owns the memory of the associated TransactionLog 
92
   * and its index - so we have to track it. 
93
   */
94
  TransactionLog *transaction_log;
95
  TransactionLogIndex *transaction_log_index;
1405.4.1 by Jay Pipes
Adds a vector of write buffers to the transaction log applier
96
  uint32_t num_write_buffers; ///< Number of write buffers used
97
  std::vector<WriteBuffer *> write_buffers; ///< array of write buffers
98
99
  /**
100
   * Returns the write buffer for the supplied session
101
   *
102
   * @param Session descriptor
103
   */
104
  WriteBuffer *getWriteBuffer(const drizzled::Session &session);
1273.22.1 by Jay Pipes
Completes the blueprint for refactoring applier out of log descriptor.
105
};
106
107
#endif /* PLUGIN_TRANSACTION_LOG_TRANSACTION_LOG_APPLIER_H */