1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef qpid_broker_AsyncStore_h_
#define qpid_broker_AsyncStore_h_
#include "qpid/broker/RecoveryManager.h"
#include "qpid/types/Variant.h" // qpid::types::Variant::Map
#include <boost/shared_ptr.hpp>
#include <stdint.h> // uint64_t
#include <string>
namespace qpid {
namespace broker {
// This handle carries async op results
class AsyncResultHandle;
// Broker to subclass as a pollable queue
class AsyncResultQueue {
public:
virtual ~AsyncResultQueue() {}
virtual void submit(boost::shared_ptr<AsyncResultHandle>) = 0;
};
// Subclass this for specific contexts
class BrokerAsyncContext {
public:
virtual ~BrokerAsyncContext() {}
virtual AsyncResultQueue* getAsyncResultQueue() const = 0;
virtual void invokeCallback(const AsyncResultHandle* const) const = 0;
void setOpStr(const char* opStr) { m_opStr = opStr; }
const char* getOpStr() const { return m_opStr; }
private:
const char* m_opStr;
};
class DataSource {
public:
virtual ~DataSource() {}
virtual uint64_t getSize() = 0;
virtual void write(char* target) = 0;
};
// Opaque async handles used for carrying persistence state.
class ConfigHandle;
class EnqueueHandle;
class EventHandle;
class MessageHandle;
class QueueHandle;
class RecoveryHandle;
class TxnHandle;
class InitAsyncContext;
class QueueAsyncContext;
class RecoveryAsyncContext;
class TpcTxnAsyncContext;
class TxnAsyncContext;
class SimpleTxnBuffer;
class AsyncTransactionalStore {
public:
virtual ~AsyncTransactionalStore() {}
virtual TxnHandle createTxnHandle() = 0;
virtual TxnHandle createTxnHandle(SimpleTxnBuffer* tb) = 0;
virtual TxnHandle createTxnHandle(const std::string& xid,
const bool tpcFlag) = 0;
virtual TxnHandle createTxnHandle(const std::string& xid,
const bool tpcFlag,
SimpleTxnBuffer* tb) = 0;
virtual void submitPrepare(TxnHandle&,
boost::shared_ptr<TpcTxnAsyncContext>) = 0; // Distributed txns only
virtual void submitCommit(TxnHandle&,
boost::shared_ptr<TxnAsyncContext>) = 0;
virtual void submitAbort(TxnHandle&,
boost::shared_ptr<TxnAsyncContext>) = 0;
};
class AsyncRecoverable {
public:
virtual ~AsyncRecoverable() {}
virtual RecoveryHandle createRecoveryHandle() = 0;
virtual void submitRecover(qpid::broker::RecoveryHandle&,
boost::shared_ptr<qpid::broker::RecoveryAsyncContext>) = 0;
};
// Subclassed by store:
class AsyncStore : public AsyncTransactionalStore,
public AsyncRecoverable {
public:
virtual ~AsyncStore() {}
virtual void initialize(bool truncateFlag = false, bool saveFlag = true) = 0;
// --- Factory methods for creating handles ---
virtual ConfigHandle createConfigHandle() = 0;
virtual EnqueueHandle createEnqueueHandle(MessageHandle&,
QueueHandle&) = 0;
virtual EventHandle createEventHandle(QueueHandle&,
const std::string& key=std::string()) = 0;
virtual MessageHandle createMessageHandle(const DataSource* const) = 0;
virtual QueueHandle createQueueHandle(const std::string& name,
const qpid::types::Variant::Map& opts) = 0;
// --- Store async interface ---
// TODO: Switch from BrokerAsyncContext (parent class) to ConfigAsyncContext
// when theses features (and async context classes) are developed.
virtual void submitCreate(ConfigHandle&,
const DataSource* const,
boost::shared_ptr<BrokerAsyncContext>) = 0;
virtual void submitDestroy(ConfigHandle&,
boost::shared_ptr<BrokerAsyncContext>) = 0;
virtual void submitCreate(QueueHandle&,
const DataSource* const,
boost::shared_ptr<QueueAsyncContext>) = 0;
virtual void submitDestroy(QueueHandle&,
boost::shared_ptr<QueueAsyncContext>) = 0;
virtual void submitFlush(QueueHandle&,
boost::shared_ptr<QueueAsyncContext>) = 0;
// TODO: Switch from BrokerAsyncContext (parent class) to EventAsyncContext
// when theses features (and async context classes) are developed.
virtual void submitCreate(EventHandle&,
const DataSource* const,
TxnHandle&,
boost::shared_ptr<BrokerAsyncContext>) = 0;
virtual void submitDestroy(EventHandle&,
TxnHandle&,
boost::shared_ptr<BrokerAsyncContext>) = 0;
virtual void submitEnqueue(EnqueueHandle&,
TxnHandle&,
boost::shared_ptr<QueueAsyncContext>) = 0;
virtual void submitDequeue(EnqueueHandle&,
TxnHandle&,
boost::shared_ptr<QueueAsyncContext>) = 0;
// // Legacy - Restore FTD message, is NOT async!
// virtual int loadContent(MessageHandle&,
// QueueHandle&,
// char* data,
// uint64_t offset,
// const uint64_t length) = 0;
};
}} // namespace qpid::broker
#endif // qpid_broker_AsyncStore_h_
|