summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/asyncStore/AsyncStoreImpl.h
blob: 7e3b3e94dab0332025103625cc2dbab8c195e0b3 (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
/*
 * 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.h
 */

#ifndef qpid_asyncStore_AsyncStoreImpl_h_
#define qpid_asyncStore_AsyncStoreImpl_h_

#include "AsyncStoreOptions.h"
#include "RunState.h"
#include "OperationQueue.h"

#include "qpid/asyncStore/jrnl2/RecordIdCounter.h"
#include "qpid/broker/AsyncStore.h"
#include "qpid/sys/Poller.h"

namespace qpid {

namespace broker {
class Broker;
} // namespace qpid::broker

namespace asyncStore {

class AsyncStoreImpl: public qpid::broker::AsyncStore {
public:
    AsyncStoreImpl(boost::shared_ptr<qpid::sys::Poller> poller,
                   const AsyncStoreOptions& opts);
    virtual ~AsyncStoreImpl();
    void initialize();
    uint64_t getNextRid();

    // Management

    void initManagement(qpid::broker::Broker* broker);

    // AsyncStore interface

    qpid::broker::TxnHandle createTxnHandle(const std::string& xid=std::string());
    qpid::broker::ConfigHandle createConfigHandle();
    qpid::broker::QueueHandle createQueueHandle(const std::string& name,
                                                const qpid::types::Variant::Map& opts);
    qpid::broker::EventHandle createEventHandle(qpid::broker::QueueHandle& queueHandle,
                                                const std::string& key=std::string());
    qpid::broker::MessageHandle createMessageHandle(const qpid::broker::DataSource* dataSrc);
    qpid::broker::EnqueueHandle createEnqueueHandle(qpid::broker::MessageHandle& msgHandle,
                                                    qpid::broker::QueueHandle& queueHandle);

    void submitPrepare(qpid::broker::TxnHandle& txnHandle,
                       qpid::broker::ResultCallback resultCb,
                       qpid::broker::BrokerAsyncContext* brokerCtxt);
    void submitCommit(qpid::broker::TxnHandle& txnHandle,
                      qpid::broker::ResultCallback resultCb,
                      qpid::broker::BrokerAsyncContext* brokerCtxt);
    void submitAbort(qpid::broker::TxnHandle& txnHandle,
                     qpid::broker::ResultCallback resultCb,
                     qpid::broker::BrokerAsyncContext* brokerCtxt);

    void submitCreate(qpid::broker::ConfigHandle& cfgHandle,
                      const qpid::broker::DataSource* dataSrc,
                      qpid::broker::ResultCallback resultCb,
                      qpid::broker::BrokerAsyncContext* brokerCtxt);
    void submitDestroy(qpid::broker::ConfigHandle& cfgHandle,
                       qpid::broker::ResultCallback resultCb,
                       qpid::broker::BrokerAsyncContext* brokerCtxt);

    void submitCreate(qpid::broker::QueueHandle& queueHandle,
                      const qpid::broker::DataSource* dataSrc,
                      qpid::broker::ResultCallback resultCb,
                      qpid::broker::BrokerAsyncContext* brokerCtxt);
    void submitDestroy(qpid::broker::QueueHandle& queueHandle,
                       qpid::broker::ResultCallback resultCb,
                       qpid::broker::BrokerAsyncContext* brokerCtxt);
    void submitFlush(qpid::broker::QueueHandle& queueHandle,
                     qpid::broker::ResultCallback resultCb,
                     qpid::broker::BrokerAsyncContext* brokerCtxt);

    void submitCreate(qpid::broker::EventHandle& eventHandle,
                      const qpid::broker::DataSource* dataSrc,
                      qpid::broker::ResultCallback resultCb,
                      qpid::broker::BrokerAsyncContext* brokerCtxt);
    void submitCreate(qpid::broker::EventHandle& eventHandle,
                      const qpid::broker::DataSource* dataSrc,
                      qpid::broker::TxnHandle& txnHandle,
                      qpid::broker::ResultCallback resultCb,
                      qpid::broker::BrokerAsyncContext* brokerCtxt);
    void submitDestroy(qpid::broker::EventHandle& eventHandle,
                      qpid::broker::ResultCallback resultCb,
                      qpid::broker::BrokerAsyncContext* brokerCtxt);
    void submitDestroy(qpid::broker::EventHandle& eventHandle,
                      qpid::broker::TxnHandle& txnHandle,
                      qpid::broker::ResultCallback resultCb,
                      qpid::broker::BrokerAsyncContext* brokerCtxt);

    void submitEnqueue(qpid::broker::EnqueueHandle& enqHandle,
                       qpid::broker::ResultCallback resultCb,
                       qpid::broker::BrokerAsyncContext* brokerCtxt);
    void submitEnqueue(qpid::broker::EnqueueHandle& enqHandle,
                       qpid::broker::TxnHandle& txnHandle,
                       qpid::broker::ResultCallback resultCb,
                       qpid::broker::BrokerAsyncContext* brokerCtxt);
    void submitDequeue(qpid::broker::EnqueueHandle& enqHandle,
                       qpid::broker::ResultCallback resultCb,
                       qpid::broker::BrokerAsyncContext* brokerCtxt);
    void submitDequeue(qpid::broker::EnqueueHandle& enqHandle,
                       qpid::broker::TxnHandle& txnHandle,
                       qpid::broker::ResultCallback resultCb,
                       qpid::broker::BrokerAsyncContext* brokerCtxt);

    // Legacy - Restore FTD message, is NOT async!
    virtual int loadContent(qpid::broker::MessageHandle& msgHandle,
                            qpid::broker::QueueHandle& queueHandle,
                            char* data,
                            uint64_t offset,
                            const uint64_t length);

protected:
    boost::shared_ptr<qpid::sys::Poller> m_poller;
    AsyncStoreOptions m_opts;
    RunState m_runState;
    OperationQueue m_operations;
    qpid::asyncStore::jrnl2::RecordIdCounter_t m_ridCntr;
};

}} // namespace qpid::asyncStore

#endif // qpid_asyncStore_AsyncStoreImpl_h_