summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/asyncStore/AsyncStoreImpl.cpp
blob: 9c1ff42fa2bcec8d809c3d9258a7c58c0a0d4027 (plain)
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/*
 * 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.
 */

/**
 * \file AsyncStoreImpl.cpp
 */

#include "qpid/asyncStore/AsyncStoreImpl.h"

#include "qpid/asyncStore/AsyncOperation.h"
#include "qpid/asyncStore/ConfigHandleImpl.h"
#include "qpid/asyncStore/EnqueueHandleImpl.h"
#include "qpid/asyncStore/EventHandleImpl.h"
#include "qpid/asyncStore/MessageHandleImpl.h"
#include "qpid/asyncStore/QueueHandleImpl.h"
#include "qpid/asyncStore/TxnHandleImpl.h"
#include "qpid/broker/ConfigHandle.h"
#include "qpid/broker/EnqueueHandle.h"
#include "qpid/broker/EventHandle.h"
#include "qpid/broker/MessageHandle.h"
#include "qpid/broker/QueueAsyncContext.h"
#include "qpid/broker/QueueHandle.h"
#include "qpid/broker/TxnAsyncContext.h"
#include "qpid/broker/TxnHandle.h"

namespace qpid {
namespace asyncStore {

AsyncStoreImpl::AsyncStoreImpl(boost::shared_ptr<qpid::sys::Poller> poller,
                               const AsyncStoreOptions& opts) :
        m_poller(poller),
        m_opts(opts),
        m_runState(),
        m_operations(m_poller)
{}

AsyncStoreImpl::~AsyncStoreImpl() {}

void
AsyncStoreImpl::initialize() {}

uint64_t
AsyncStoreImpl::getNextRid() {
    return m_ridCntr.next();
}

void
AsyncStoreImpl::initManagement(qpid::broker::Broker* /*broker*/) {}

qpid::broker::TxnHandle
AsyncStoreImpl::createTxnHandle() {
    return qpid::broker::TxnHandle(new TxnHandleImpl);
}

qpid::broker::TxnHandle
AsyncStoreImpl::createTxnHandle(qpid::broker::SimpleTxnBuffer* tb) {
    return qpid::broker::TxnHandle(new TxnHandleImpl(tb));
}

qpid::broker::TxnHandle
AsyncStoreImpl::createTxnHandle(const std::string& xid,
                                const bool tpcFlag) {
    return qpid::broker::TxnHandle(new TxnHandleImpl(xid, tpcFlag));
}

qpid::broker::TxnHandle
AsyncStoreImpl::createTxnHandle(const std::string& xid,
                                const bool tpcFlag,
                                qpid::broker::SimpleTxnBuffer* tb) {
    return qpid::broker::TxnHandle(new TxnHandleImpl(xid, tpcFlag, tb));
}

void
AsyncStoreImpl::submitPrepare(qpid::broker::TxnHandle& txnHandle,
                              boost::shared_ptr<qpid::broker::TpcTxnAsyncContext> TxnCtxt) {
    boost::shared_ptr<const AsyncOperation> op(new AsyncOpTxnPrepare(txnHandle, TxnCtxt, this));
    TxnCtxt->setOpStr(op->getOpStr());
    m_operations.submit(op);
}

void
AsyncStoreImpl::submitCommit(qpid::broker::TxnHandle& txnHandle,
                             boost::shared_ptr<qpid::broker::TxnAsyncContext> TxnCtxt) {
    boost::shared_ptr<const AsyncOperation> op(new AsyncOpTxnCommit(txnHandle, TxnCtxt, this));
    TxnCtxt->setOpStr(op->getOpStr());
    m_operations.submit(op);
}

void
AsyncStoreImpl::submitAbort(qpid::broker::TxnHandle& txnHandle,
                            boost::shared_ptr<qpid::broker::TxnAsyncContext> TxnCtxt) {
    boost::shared_ptr<const AsyncOperation> op(new AsyncOpTxnAbort(txnHandle, TxnCtxt, this));
    TxnCtxt->setOpStr(op->getOpStr());
    m_operations.submit(op);
}

qpid::broker::ConfigHandle
AsyncStoreImpl::createConfigHandle() {
    return qpid::broker::ConfigHandle(new ConfigHandleImpl());
}

qpid::broker::EnqueueHandle
AsyncStoreImpl::createEnqueueHandle(qpid::broker::MessageHandle& msgHandle,
                                    qpid::broker::QueueHandle& queueHandle) {
    return qpid::broker::EnqueueHandle(new EnqueueHandleImpl(msgHandle,
                                                             queueHandle));
}

qpid::broker::EventHandle
AsyncStoreImpl::createEventHandle(qpid::broker::QueueHandle& queueHandle,
                                  const std::string& key) {
    return qpid::broker::EventHandle(new EventHandleImpl(queueHandle,
                                                         key));
}

qpid::broker::MessageHandle
AsyncStoreImpl::createMessageHandle(const qpid::broker::DataSource* const dataSrc) {
    return qpid::broker::MessageHandle(new MessageHandleImpl(dataSrc));
}

qpid::broker::QueueHandle
AsyncStoreImpl::createQueueHandle(const std::string& name,
                                  const qpid::types::Variant::Map& opts) {
    return qpid::broker::QueueHandle(new QueueHandleImpl(name, opts));
}

void
AsyncStoreImpl::submitCreate(qpid::broker::ConfigHandle& cfgHandle,
                             const qpid::broker::DataSource* const dataSrc,
                             boost::shared_ptr<qpid::broker::BrokerAsyncContext> brokerCtxt) {
    boost::shared_ptr<const AsyncOperation> op(new AsyncOpConfigCreate(cfgHandle, dataSrc, brokerCtxt, this));
    brokerCtxt->setOpStr(op->getOpStr());
    m_operations.submit(op);
}

void
AsyncStoreImpl::submitDestroy(qpid::broker::ConfigHandle& cfgHandle,
                              boost::shared_ptr<qpid::broker::BrokerAsyncContext> brokerCtxt) {
    boost::shared_ptr<const AsyncOperation> op(new AsyncOpConfigDestroy(cfgHandle, brokerCtxt, this));
    brokerCtxt->setOpStr(op->getOpStr());
    m_operations.submit(op);
}

void
AsyncStoreImpl::submitCreate(qpid::broker::QueueHandle& queueHandle,
                             const qpid::broker::DataSource* const dataSrc,
                             boost::shared_ptr<qpid::broker::QueueAsyncContext> QueueCtxt) {
    boost::shared_ptr<const AsyncOperation> op(new AsyncOpQueueCreate(queueHandle, dataSrc, QueueCtxt, this));
    QueueCtxt->setOpStr(op->getOpStr());
    m_operations.submit(op);
}

void
AsyncStoreImpl::submitDestroy(qpid::broker::QueueHandle& queueHandle,
                              boost::shared_ptr<qpid::broker::QueueAsyncContext> QueueCtxt) {
    boost::shared_ptr<const AsyncOperation> op(new AsyncOpQueueDestroy(queueHandle, QueueCtxt, this));
    QueueCtxt->setOpStr(op->getOpStr());
    m_operations.submit(op);
}

void
AsyncStoreImpl::submitFlush(qpid::broker::QueueHandle& queueHandle,
                            boost::shared_ptr<qpid::broker::QueueAsyncContext> QueueCtxt) {
    boost::shared_ptr<const AsyncOperation> op(new AsyncOpQueueFlush(queueHandle, QueueCtxt, this));
    QueueCtxt->setOpStr(op->getOpStr());
    m_operations.submit(op);
}

void
AsyncStoreImpl::submitCreate(qpid::broker::EventHandle& eventHandle,
                             const qpid::broker::DataSource* const dataSrc,
                             qpid::broker::TxnHandle& txnHandle,
                             boost::shared_ptr<qpid::broker::BrokerAsyncContext> brokerCtxt) {
    boost::shared_ptr<const AsyncOperation> op(new AsyncOpEventCreate(eventHandle, dataSrc, txnHandle, brokerCtxt, this));
    brokerCtxt->setOpStr(op->getOpStr());
    m_operations.submit(op);
}

void
AsyncStoreImpl::submitDestroy(qpid::broker::EventHandle& eventHandle,
                              qpid::broker::TxnHandle& txnHandle,
                              boost::shared_ptr<qpid::broker::BrokerAsyncContext> brokerCtxt) {
    boost::shared_ptr<const AsyncOperation> op(new AsyncOpEventDestroy(eventHandle, txnHandle, brokerCtxt, this));
    brokerCtxt->setOpStr(op->getOpStr());
    m_operations.submit(op);
}

void
AsyncStoreImpl::submitEnqueue(qpid::broker::EnqueueHandle& enqHandle,
                              qpid::broker::TxnHandle& txnHandle,
                              boost::shared_ptr<qpid::broker::QueueAsyncContext> QueueCtxt) {
    boost::shared_ptr<const AsyncOperation> op(new AsyncOpMsgEnqueue(enqHandle, txnHandle, QueueCtxt, this));
    QueueCtxt->setOpStr(op->getOpStr());
    m_operations.submit(op);
}

void
AsyncStoreImpl::submitDequeue(qpid::broker::EnqueueHandle& enqHandle,
                              qpid::broker::TxnHandle& txnHandle,
                              boost::shared_ptr<qpid::broker::QueueAsyncContext> QueueCtxt) {
    boost::shared_ptr<const AsyncOperation> op(new AsyncOpMsgDequeue(enqHandle, txnHandle, QueueCtxt, this));
    QueueCtxt->setOpStr(op->getOpStr());
    m_operations.submit(op);
}

int
AsyncStoreImpl::loadContent(qpid::broker::MessageHandle& /*msgHandle*/,
                            qpid::broker::QueueHandle& /*queueHandle*/,
                            char* /*data*/,
                            uint64_t /*offset*/,
                            const uint64_t /*length*/) {
    return 0;
}

}} // namespace qpid::asyncStore