1447e01b9STrond Norbye /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2447e01b9STrond Norbye /*
3447e01b9STrond Norbye  *     Copyright 2016 Couchbase, Inc
4447e01b9STrond Norbye  *
5447e01b9STrond Norbye  *   Licensed under the Apache License, Version 2.0 (the "License");
6447e01b9STrond Norbye  *   you may not use this file except in compliance with the License.
7447e01b9STrond Norbye  *   You may obtain a copy of the License at
8447e01b9STrond Norbye  *
9447e01b9STrond Norbye  *       http://www.apache.org/licenses/LICENSE-2.0
10447e01b9STrond Norbye  *
11447e01b9STrond Norbye  *   Unless required by applicable law or agreed to in writing, software
12447e01b9STrond Norbye  *   distributed under the License is distributed on an "AS IS" BASIS,
13447e01b9STrond Norbye  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14447e01b9STrond Norbye  *   See the License for the specific language governing permissions and
15447e01b9STrond Norbye  *   limitations under the License.
16447e01b9STrond Norbye  */
17447e01b9STrond Norbye 
18447e01b9STrond Norbye #include "config.h"
19447e01b9STrond Norbye #include "nobucket.h"
20447e01b9STrond Norbye 
21447e01b9STrond Norbye #include <cstdlib>
22447e01b9STrond Norbye #include <stdexcept>
23447e01b9STrond Norbye #include <string>
24447e01b9STrond Norbye 
25447e01b9STrond Norbye /**
26447e01b9STrond Norbye  * The NoBucket is a bucket that just returns "ENGINE_NO_BUCKET" for "all"
27447e01b9STrond Norbye  * operations. The main purpose for having this bucket is to reduce the
28447e01b9STrond Norbye  * code complexity so we don't have to had checks all over the place to
29447e01b9STrond Norbye  * see if a client is connected to a bucket or not (we may just associate
30447e01b9STrond Norbye  * the connection to this bucket and it'll handle the appropriate
31447e01b9STrond Norbye  * command.
32447e01b9STrond Norbye  */
33447e01b9STrond Norbye class NoBucket : public ENGINE_HANDLE_V1 {
34447e01b9STrond Norbye public:
NoBucket()35447e01b9STrond Norbye     NoBucket() {
36447e01b9STrond Norbye         memset(this, 0, sizeof(*this));
37447e01b9STrond Norbye         ENGINE_HANDLE_V1::interface.interface = 1;
38447e01b9STrond Norbye         ENGINE_HANDLE_V1::initialize = initialize;
39447e01b9STrond Norbye         ENGINE_HANDLE_V1::destroy = destroy;
40447e01b9STrond Norbye         ENGINE_HANDLE_V1::allocate = item_allocate;
41ef300e4fSTrond Norbye         ENGINE_HANDLE_V1::allocate_ex = item_allocate_ex;
42447e01b9STrond Norbye         ENGINE_HANDLE_V1::remove = item_delete;
43447e01b9STrond Norbye         ENGINE_HANDLE_V1::release = item_release;
44447e01b9STrond Norbye         ENGINE_HANDLE_V1::get = get;
45f4ca6db8STrond Norbye         ENGINE_HANDLE_V1::get_meta = get_meta;
46df8b8966STrond Norbye         ENGINE_HANDLE_V1::get_if = get_if;
47d9cae79dSTrond Norbye         ENGINE_HANDLE_V1::get_and_touch = get_and_touch;
48eee49ccfSTrond Norbye         ENGINE_HANDLE_V1::get_locked = get_locked;
49eee49ccfSTrond Norbye         ENGINE_HANDLE_V1::unlock = unlock;
50447e01b9STrond Norbye         ENGINE_HANDLE_V1::get_stats = get_stats;
51447e01b9STrond Norbye         ENGINE_HANDLE_V1::reset_stats = reset_stats;
52447e01b9STrond Norbye         ENGINE_HANDLE_V1::store = store;
538f9005d0SJim Walker         ENGINE_HANDLE_V1::store_if = store_if;
54447e01b9STrond Norbye         ENGINE_HANDLE_V1::flush = flush;
55447e01b9STrond Norbye         ENGINE_HANDLE_V1::unknown_command = unknown_command;
56447e01b9STrond Norbye         ENGINE_HANDLE_V1::item_set_cas = item_set_cas;
576f86aa1eSTim Bradgate         ENGINE_HANDLE_V1::item_set_datatype = item_set_datatype;
58447e01b9STrond Norbye         ENGINE_HANDLE_V1::get_item_info = get_item_info;
59447e01b9STrond Norbye         ENGINE_HANDLE_V1::set_item_info = set_item_info;
60447e01b9STrond Norbye         ENGINE_HANDLE_V1::dcp.step = dcp_step;
61447e01b9STrond Norbye         ENGINE_HANDLE_V1::dcp.open = dcp_open;
62447e01b9STrond Norbye         ENGINE_HANDLE_V1::dcp.add_stream = dcp_add_stream;
63447e01b9STrond Norbye         ENGINE_HANDLE_V1::dcp.close_stream = dcp_close_stream;
64447e01b9STrond Norbye         ENGINE_HANDLE_V1::dcp.get_failover_log = dcp_get_failover_log;
65447e01b9STrond Norbye         ENGINE_HANDLE_V1::dcp.stream_req = dcp_stream_req;
66447e01b9STrond Norbye         ENGINE_HANDLE_V1::dcp.stream_end = dcp_stream_end;
67447e01b9STrond Norbye         ENGINE_HANDLE_V1::dcp.snapshot_marker = dcp_snapshot_marker;
68447e01b9STrond Norbye         ENGINE_HANDLE_V1::dcp.mutation = dcp_mutation;
69447e01b9STrond Norbye         ENGINE_HANDLE_V1::dcp.deletion = dcp_deletion;
7043afbf69SJim Walker         ENGINE_HANDLE_V1::dcp.deletion_v2 = dcp_deletion_v2;
71447e01b9STrond Norbye         ENGINE_HANDLE_V1::dcp.expiration = dcp_expiration;
72447e01b9STrond Norbye         ENGINE_HANDLE_V1::dcp.flush = dcp_flush;
73447e01b9STrond Norbye         ENGINE_HANDLE_V1::dcp.set_vbucket_state = dcp_set_vbucket_state;
740adf72a1SJim Walker         ENGINE_HANDLE_V1::dcp.system_event = dcp_system_event;
757e325d3eSJim Walker         ENGINE_HANDLE_V1::collections.set_manifest = collections_set_manifest;
76901d1ab8SJim Walker         ENGINE_HANDLE_V1::collections.get_manifest = collections_get_manifest;
7786724888SJim Walker         ENGINE_HANDLE_V1::isXattrEnabled = isXattrEnabled;
78*1ed4a1e8SSriram Ganesan         ENGINE_HANDLE_V1::getMaxItemSize = getMaxItemSize;
79447e01b9STrond Norbye     };
80447e01b9STrond Norbye 
81447e01b9STrond Norbye private:
82447e01b9STrond Norbye     /**
83447e01b9STrond Norbye      * Convert the ENGINE_HANDLE to the underlying class type
84447e01b9STrond Norbye      *
85447e01b9STrond Norbye      * @param handle the handle as provided by the frontend
86447e01b9STrond Norbye      * @return the actual no bucket object
87447e01b9STrond Norbye      */
get_handle(ENGINE_HANDLE * handle)88447e01b9STrond Norbye     static NoBucket* get_handle(ENGINE_HANDLE* handle) {
89447e01b9STrond Norbye         return reinterpret_cast<NoBucket*>(handle);
90447e01b9STrond Norbye     }
91447e01b9STrond Norbye 
initialize(gsl::not_null<ENGINE_HANDLE * >,const char *)92aacf24fdSTrond Norbye     static ENGINE_ERROR_CODE initialize(gsl::not_null<ENGINE_HANDLE*>,
93aacf24fdSTrond Norbye                                         const char*) {
94447e01b9STrond Norbye         return ENGINE_SUCCESS;
95447e01b9STrond Norbye     }
96447e01b9STrond Norbye 
destroy(gsl::not_null<ENGINE_HANDLE * > handle,const bool)97aacf24fdSTrond Norbye     static void destroy(gsl::not_null<ENGINE_HANDLE*> handle, const bool) {
98447e01b9STrond Norbye         delete get_handle(handle);
99447e01b9STrond Norbye     }
100447e01b9STrond Norbye 
item_allocate(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * >,const DocKey &,const size_t,const int,const rel_time_t,uint8_t,uint16_t)101aacf24fdSTrond Norbye     static cb::EngineErrorItemPair item_allocate(gsl::not_null<ENGINE_HANDLE*>,
1020d8ac478STrond Norbye                                                  gsl::not_null<const void*>,
103b67a513dSolivermd                                                  const DocKey&,
104b67a513dSolivermd                                                  const size_t,
105b67a513dSolivermd                                                  const int,
106b67a513dSolivermd                                                  const rel_time_t,
107b67a513dSolivermd                                                  uint8_t,
108b67a513dSolivermd                                                  uint16_t) {
109b67a513dSolivermd         return cb::makeEngineErrorItemPair(cb::engine_errc::no_bucket);
110447e01b9STrond Norbye     }
111447e01b9STrond Norbye 
item_allocate_ex(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * > cookie,const DocKey &,size_t,size_t,int,rel_time_t,uint8_t,uint16_t)112aacf24fdSTrond Norbye     static std::pair<cb::unique_item_ptr, item_info> item_allocate_ex(
113aacf24fdSTrond Norbye             gsl::not_null<ENGINE_HANDLE*>,
114991c7667STrond Norbye             gsl::not_null<const void*> cookie,
115ef300e4fSTrond Norbye             const DocKey&,
116991c7667STrond Norbye             size_t,
117991c7667STrond Norbye             size_t,
118991c7667STrond Norbye             int,
119991c7667STrond Norbye             rel_time_t,
120ef300e4fSTrond Norbye             uint8_t,
121ef300e4fSTrond Norbye             uint16_t) {
122ef300e4fSTrond Norbye         throw cb::engine_error(cb::engine_errc::no_bucket, "no bucket");
123ef300e4fSTrond Norbye     }
124ef300e4fSTrond Norbye 
item_delete(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * >,const DocKey &,uint64_t &,uint16_t,mutation_descr_t &)125aacf24fdSTrond Norbye     static ENGINE_ERROR_CODE item_delete(gsl::not_null<ENGINE_HANDLE*>,
1264fc85e3eSTrond Norbye                                          gsl::not_null<const void*>,
127aacf24fdSTrond Norbye                                          const DocKey&,
1284fc85e3eSTrond Norbye                                          uint64_t&,
129aacf24fdSTrond Norbye                                          uint16_t,
1304fc85e3eSTrond Norbye                                          mutation_descr_t&) {
131447e01b9STrond Norbye         return ENGINE_NO_BUCKET;
132447e01b9STrond Norbye     }
133447e01b9STrond Norbye 
item_release(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<item * >)134aacf24fdSTrond Norbye     static void item_release(gsl::not_null<ENGINE_HANDLE*>,
135aacf24fdSTrond Norbye                              gsl::not_null<item*>) {
136447e01b9STrond Norbye         throw std::logic_error("NoBucket::item_release: no items should have"
137447e01b9STrond Norbye                                    " been allocated from this engine");
138447e01b9STrond Norbye     }
139447e01b9STrond Norbye 
get(gsl::not_null<ENGINE_HANDLE * > h,gsl::not_null<const void * >,const DocKey &,uint16_t,DocStateFilter)140aacf24fdSTrond Norbye     static cb::EngineErrorItemPair get(gsl::not_null<ENGINE_HANDLE*> h,
141bf434e33STrond Norbye                                        gsl::not_null<const void*>,
142f068119eSTrond Norbye                                        const DocKey&,
143f068119eSTrond Norbye                                        uint16_t,
144f068119eSTrond Norbye                                        DocStateFilter) {
1459130880eSolivermd         return cb::makeEngineErrorItemPair(cb::engine_errc::no_bucket);
146447e01b9STrond Norbye     }
147447e01b9STrond Norbye 
get_meta(gsl::not_null<ENGINE_HANDLE * > handle,gsl::not_null<const void * > cookie,const DocKey & key,uint16_t vbucket)148f4ca6db8STrond Norbye     static cb::EngineErrorMetadataPair get_meta(
149f4ca6db8STrond Norbye             gsl::not_null<ENGINE_HANDLE*> handle,
150f4ca6db8STrond Norbye             gsl::not_null<const void*> cookie,
151f4ca6db8STrond Norbye             const DocKey& key,
152f4ca6db8STrond Norbye             uint16_t vbucket) {
153f4ca6db8STrond Norbye         return cb::EngineErrorMetadataPair(cb::engine_errc::no_bucket, {});
154f4ca6db8STrond Norbye     }
155f4ca6db8STrond Norbye 
get_if(gsl::not_null<ENGINE_HANDLE * > handle,gsl::not_null<const void * >,const DocKey &,uint16_t,std::function<bool (const item_info &)>)156aacf24fdSTrond Norbye     static cb::EngineErrorItemPair get_if(
157aacf24fdSTrond Norbye             gsl::not_null<ENGINE_HANDLE*> handle,
158c5a5199aSTrond Norbye             gsl::not_null<const void*>,
159df8b8966STrond Norbye             const DocKey&,
160df8b8966STrond Norbye             uint16_t,
161aacf24fdSTrond Norbye             std::function<bool(const item_info&)>) {
162c382cb4aSolivermd         return cb::makeEngineErrorItemPair(cb::engine_errc::no_bucket);
163df8b8966STrond Norbye     }
164df8b8966STrond Norbye 
get_and_touch(gsl::not_null<ENGINE_HANDLE * > handle,gsl::not_null<const void * > cookie,const DocKey &,uint16_t,uint32_t)165aacf24fdSTrond Norbye     static cb::EngineErrorItemPair get_and_touch(
166aacf24fdSTrond Norbye             gsl::not_null<ENGINE_HANDLE*> handle,
167b8f14bcaSTrond Norbye             gsl::not_null<const void*> cookie,
168d9cae79dSTrond Norbye             const DocKey&,
169d9cae79dSTrond Norbye             uint16_t,
170d9cae79dSTrond Norbye             uint32_t) {
171c382cb4aSolivermd         return cb::makeEngineErrorItemPair(cb::engine_errc::no_bucket);
172d9cae79dSTrond Norbye     }
173d9cae79dSTrond Norbye 
get_locked(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * >,const DocKey &,uint16_t,uint32_t)174aacf24fdSTrond Norbye     static cb::EngineErrorItemPair get_locked(gsl::not_null<ENGINE_HANDLE*>,
175b92e94e4STrond Norbye                                               gsl::not_null<const void*>,
176aacf24fdSTrond Norbye                                               const DocKey&,
177aacf24fdSTrond Norbye                                               uint16_t,
178aacf24fdSTrond Norbye                                               uint32_t) {
1799f6f10a0Solivermd         return cb::makeEngineErrorItemPair(cb::engine_errc::no_bucket);
180eee49ccfSTrond Norbye     }
181eee49ccfSTrond Norbye 
unlock(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * >,const DocKey &,uint16_t,uint64_t)182aacf24fdSTrond Norbye     static ENGINE_ERROR_CODE unlock(gsl::not_null<ENGINE_HANDLE*>,
183b92e94e4STrond Norbye                                     gsl::not_null<const void*>,
184aacf24fdSTrond Norbye                                     const DocKey&,
185aacf24fdSTrond Norbye                                     uint16_t,
186aacf24fdSTrond Norbye                                     uint64_t) {
187eee49ccfSTrond Norbye         return ENGINE_NO_BUCKET;
188eee49ccfSTrond Norbye     }
189eee49ccfSTrond Norbye 
get_stats(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * >,cb::const_char_buffer key,ADD_STAT)190aacf24fdSTrond Norbye     static ENGINE_ERROR_CODE get_stats(gsl::not_null<ENGINE_HANDLE*>,
191f9c178f3STrond Norbye                                        gsl::not_null<const void*>,
192f9c178f3STrond Norbye                                        cb::const_char_buffer key,
193aacf24fdSTrond Norbye                                        ADD_STAT) {
1948b324ff5STrond Norbye         return ENGINE_NO_BUCKET;
195447e01b9STrond Norbye     }
196447e01b9STrond Norbye 
store(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * >,gsl::not_null<item * >,uint64_t &,ENGINE_STORE_OPERATION,DocumentState)197aacf24fdSTrond Norbye     static ENGINE_ERROR_CODE store(gsl::not_null<ENGINE_HANDLE*>,
198393b038aSTrond Norbye                                    gsl::not_null<const void*>,
199aacf24fdSTrond Norbye                                    gsl::not_null<item*>,
200393b038aSTrond Norbye                                    uint64_t&,
201aacf24fdSTrond Norbye                                    ENGINE_STORE_OPERATION,
2021a3c37bdSTrond Norbye                                    DocumentState) {
203447e01b9STrond Norbye         return ENGINE_NO_BUCKET;
204447e01b9STrond Norbye     }
205447e01b9STrond Norbye 
store_if(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * >,gsl::not_null<item * >,uint64_t,ENGINE_STORE_OPERATION,cb::StoreIfPredicate,DocumentState)206aacf24fdSTrond Norbye     static cb::EngineErrorCasPair store_if(gsl::not_null<ENGINE_HANDLE*>,
207fea26fa3STrond Norbye                                            gsl::not_null<const void*>,
208aacf24fdSTrond Norbye                                            gsl::not_null<item*>,
2098f9005d0SJim Walker                                            uint64_t,
2108f9005d0SJim Walker                                            ENGINE_STORE_OPERATION,
2118f9005d0SJim Walker                                            cb::StoreIfPredicate,
2128f9005d0SJim Walker                                            DocumentState) {
2138f9005d0SJim Walker         return {cb::engine_errc::no_bucket, 0};
2148f9005d0SJim Walker     }
2158f9005d0SJim Walker 
flush(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * >)216f12f559eSTrond Norbye     static ENGINE_ERROR_CODE flush(gsl::not_null<ENGINE_HANDLE*>,
217f12f559eSTrond Norbye                                    gsl::not_null<const void*>) {
218447e01b9STrond Norbye         return ENGINE_NO_BUCKET;
219447e01b9STrond Norbye     }
220447e01b9STrond Norbye 
reset_stats(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * > cookie)2215e233ee0STrond Norbye     static void reset_stats(gsl::not_null<ENGINE_HANDLE*>, gsl::not_null<const void*> cookie) {
222447e01b9STrond Norbye     }
223447e01b9STrond Norbye 
unknown_command(gsl::not_null<ENGINE_HANDLE * >,const void *,gsl::not_null<protocol_binary_request_header * >,ADD_RESPONSE,DocNamespace)224aacf24fdSTrond Norbye     static ENGINE_ERROR_CODE unknown_command(
225aacf24fdSTrond Norbye             gsl::not_null<ENGINE_HANDLE*>,
226aacf24fdSTrond Norbye             const void*,
227aacf24fdSTrond Norbye             gsl::not_null<protocol_binary_request_header*>,
228aacf24fdSTrond Norbye             ADD_RESPONSE,
229aacf24fdSTrond Norbye             DocNamespace) {
230447e01b9STrond Norbye         return ENGINE_NO_BUCKET;
231447e01b9STrond Norbye     }
232447e01b9STrond Norbye 
item_set_cas(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<item * >,uint64_t)233aacf24fdSTrond Norbye     static void item_set_cas(gsl::not_null<ENGINE_HANDLE*>,
234aacf24fdSTrond Norbye                              gsl::not_null<item*>,
235aacf24fdSTrond Norbye                              uint64_t) {
236447e01b9STrond Norbye         throw std::logic_error("NoBucket::item_set_cas: no items should have"
237447e01b9STrond Norbye                                    " been allocated from this engine");
238447e01b9STrond Norbye     }
239447e01b9STrond Norbye 
item_set_datatype(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<item * >,protocol_binary_datatype_t)2406f86aa1eSTim Bradgate     static void item_set_datatype(gsl::not_null<ENGINE_HANDLE*>,
2416f86aa1eSTim Bradgate                                   gsl::not_null<item*>,
2426f86aa1eSTim Bradgate                                   protocol_binary_datatype_t) {
2436f86aa1eSTim Bradgate         throw std::logic_error(
2446f86aa1eSTim Bradgate                 "NoBucket::item_set_datatype: no items should have"
2456f86aa1eSTim Bradgate                 " been allocated from this engine");
2466f86aa1eSTim Bradgate     }
2476f86aa1eSTim Bradgate 
get_item_info(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const item * >,gsl::not_null<item_info * >)248aacf24fdSTrond Norbye     static bool get_item_info(gsl::not_null<ENGINE_HANDLE*>,
249aacf24fdSTrond Norbye                               gsl::not_null<const item*>,
250aacf24fdSTrond Norbye                               gsl::not_null<item_info*>) {
251447e01b9STrond Norbye         throw std::logic_error("NoBucket::get_item_info: no items should have"
252447e01b9STrond Norbye                                    " been allocated from this engine");
253447e01b9STrond Norbye     }
254447e01b9STrond Norbye 
set_item_info(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<item * >,gsl::not_null<const item_info * >)255aacf24fdSTrond Norbye     static bool set_item_info(gsl::not_null<ENGINE_HANDLE*>,
256aacf24fdSTrond Norbye                               gsl::not_null<item*>,
257aacf24fdSTrond Norbye                               gsl::not_null<const item_info*>) {
258447e01b9STrond Norbye         throw std::logic_error("NoBucket::set_item_info: no items should have"
259447e01b9STrond Norbye                                    " been allocated from this engine");
260447e01b9STrond Norbye     }
261447e01b9STrond Norbye 
dcp_step(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * >,gsl::not_null<struct dcp_message_producers * >)262aacf24fdSTrond Norbye     static ENGINE_ERROR_CODE dcp_step(
263aacf24fdSTrond Norbye             gsl::not_null<ENGINE_HANDLE*>,
264aacf24fdSTrond Norbye             gsl::not_null<const void*>,
265aacf24fdSTrond Norbye             gsl::not_null<struct dcp_message_producers*>) {
266447e01b9STrond Norbye         return ENGINE_NO_BUCKET;
267447e01b9STrond Norbye     }
268447e01b9STrond Norbye 
dcp_open(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * >,uint32_t,uint32_t,uint32_t,cb::const_char_buffer,cb::const_byte_buffer)269aacf24fdSTrond Norbye     static ENGINE_ERROR_CODE dcp_open(gsl::not_null<ENGINE_HANDLE*>,
270aacf24fdSTrond Norbye                                       gsl::not_null<const void*>,
2719e5c4853SJim Walker                                       uint32_t,
2729e5c4853SJim Walker                                       uint32_t,
2739e5c4853SJim Walker                                       uint32_t,
2749e5c4853SJim Walker                                       cb::const_char_buffer,
2759e5c4853SJim Walker                                       cb::const_byte_buffer) {
276447e01b9STrond Norbye         return ENGINE_NO_BUCKET;
277447e01b9STrond Norbye     }
278447e01b9STrond Norbye 
dcp_add_stream(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * >,uint32_t,uint16_t,uint32_t)279aacf24fdSTrond Norbye     static ENGINE_ERROR_CODE dcp_add_stream(gsl::not_null<ENGINE_HANDLE*>,
280aacf24fdSTrond Norbye                                             gsl::not_null<const void*>,
281aacf24fdSTrond Norbye                                             uint32_t,
282aacf24fdSTrond Norbye                                             uint16_t,
283aacf24fdSTrond Norbye                                             uint32_t) {
284447e01b9STrond Norbye         return ENGINE_NO_BUCKET;
285447e01b9STrond Norbye     }
286447e01b9STrond Norbye 
dcp_close_stream(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * >,uint32_t,uint16_t)287aacf24fdSTrond Norbye     static ENGINE_ERROR_CODE dcp_close_stream(gsl::not_null<ENGINE_HANDLE*>,
288aacf24fdSTrond Norbye                                               gsl::not_null<const void*>,
289aacf24fdSTrond Norbye                                               uint32_t,
290447e01b9STrond Norbye                                               uint16_t) {
291447e01b9STrond Norbye         return ENGINE_NO_BUCKET;
292447e01b9STrond Norbye     }
293447e01b9STrond Norbye 
dcp_stream_req(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * >,uint32_t,uint32_t,uint16_t,uint64_t,uint64_t,uint64_t,uint64_t,uint64_t,uint64_t *,dcp_add_failover_log)294aacf24fdSTrond Norbye     static ENGINE_ERROR_CODE dcp_stream_req(gsl::not_null<ENGINE_HANDLE*>,
295aacf24fdSTrond Norbye                                             gsl::not_null<const void*>,
296aacf24fdSTrond Norbye                                             uint32_t,
297aacf24fdSTrond Norbye                                             uint32_t,
298aacf24fdSTrond Norbye                                             uint16_t,
299aacf24fdSTrond Norbye                                             uint64_t,
300aacf24fdSTrond Norbye                                             uint64_t,
301aacf24fdSTrond Norbye                                             uint64_t,
302aacf24fdSTrond Norbye                                             uint64_t,
303aacf24fdSTrond Norbye                                             uint64_t,
304aacf24fdSTrond Norbye                                             uint64_t*,
305aacf24fdSTrond Norbye                                             dcp_add_failover_log) {
306aacf24fdSTrond Norbye         return ENGINE_NO_BUCKET;
307aacf24fdSTrond Norbye     }
308aacf24fdSTrond Norbye 
dcp_get_failover_log(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * >,uint32_t,uint16_t,ENGINE_ERROR_CODE (*)(vbucket_failover_t *,size_t,gsl::not_null<const void * >))309aacf24fdSTrond Norbye     static ENGINE_ERROR_CODE dcp_get_failover_log(
310aacf24fdSTrond Norbye             gsl::not_null<ENGINE_HANDLE*>,
311aacf24fdSTrond Norbye             gsl::not_null<const void*>,
312aacf24fdSTrond Norbye             uint32_t,
313aacf24fdSTrond Norbye             uint16_t,
314aacf24fdSTrond Norbye             ENGINE_ERROR_CODE (*)(vbucket_failover_t*,
315aacf24fdSTrond Norbye                                   size_t,
316aacf24fdSTrond Norbye                                   gsl::not_null<const void*>)) {
317aacf24fdSTrond Norbye         return ENGINE_NO_BUCKET;
318aacf24fdSTrond Norbye     }
319aacf24fdSTrond Norbye 
dcp_stream_end(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * >,uint32_t,uint16_t,uint32_t)320aacf24fdSTrond Norbye     static ENGINE_ERROR_CODE dcp_stream_end(gsl::not_null<ENGINE_HANDLE*>,
321aacf24fdSTrond Norbye                                             gsl::not_null<const void*>,
322aacf24fdSTrond Norbye                                             uint32_t,
323aacf24fdSTrond Norbye                                             uint16_t,
324aacf24fdSTrond Norbye                                             uint32_t) {
325aacf24fdSTrond Norbye         return ENGINE_NO_BUCKET;
326aacf24fdSTrond Norbye     }
327aacf24fdSTrond Norbye 
dcp_snapshot_marker(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * >,uint32_t,uint16_t,uint64_t,uint64_t,uint32_t)328aacf24fdSTrond Norbye     static ENGINE_ERROR_CODE dcp_snapshot_marker(gsl::not_null<ENGINE_HANDLE*>,
329aacf24fdSTrond Norbye                                                  gsl::not_null<const void*>,
330aacf24fdSTrond Norbye                                                  uint32_t,
331aacf24fdSTrond Norbye                                                  uint16_t,
332aacf24fdSTrond Norbye                                                  uint64_t,
333aacf24fdSTrond Norbye                                                  uint64_t,
334aacf24fdSTrond Norbye                                                  uint32_t) {
335aacf24fdSTrond Norbye         return ENGINE_NO_BUCKET;
336aacf24fdSTrond Norbye     }
337aacf24fdSTrond Norbye 
dcp_mutation(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * >,uint32_t,const DocKey &,cb::const_byte_buffer,size_t,uint8_t,uint64_t,uint16_t,uint32_t,uint64_t,uint64_t,uint32_t,uint32_t,cb::const_byte_buffer,uint8_t)338aacf24fdSTrond Norbye     static ENGINE_ERROR_CODE dcp_mutation(gsl::not_null<ENGINE_HANDLE*>,
339aacf24fdSTrond Norbye                                           gsl::not_null<const void*>,
340aacf24fdSTrond Norbye                                           uint32_t,
341aacf24fdSTrond Norbye                                           const DocKey&,
342aacf24fdSTrond Norbye                                           cb::const_byte_buffer,
343aacf24fdSTrond Norbye                                           size_t,
344aacf24fdSTrond Norbye                                           uint8_t,
345aacf24fdSTrond Norbye                                           uint64_t,
346aacf24fdSTrond Norbye                                           uint16_t,
347aacf24fdSTrond Norbye                                           uint32_t,
348aacf24fdSTrond Norbye                                           uint64_t,
349aacf24fdSTrond Norbye                                           uint64_t,
350aacf24fdSTrond Norbye                                           uint32_t,
351aacf24fdSTrond Norbye                                           uint32_t,
352aacf24fdSTrond Norbye                                           cb::const_byte_buffer,
353aacf24fdSTrond Norbye                                           uint8_t) {
354aacf24fdSTrond Norbye         return ENGINE_NO_BUCKET;
355aacf24fdSTrond Norbye     }
356aacf24fdSTrond Norbye 
dcp_deletion(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * >,uint32_t,const DocKey &,cb::const_byte_buffer,size_t,uint8_t,uint64_t,uint16_t,uint64_t,uint64_t,cb::const_byte_buffer)357aacf24fdSTrond Norbye     static ENGINE_ERROR_CODE dcp_deletion(gsl::not_null<ENGINE_HANDLE*>,
358aacf24fdSTrond Norbye                                           gsl::not_null<const void*>,
359aacf24fdSTrond Norbye                                           uint32_t,
360aacf24fdSTrond Norbye                                           const DocKey&,
361aacf24fdSTrond Norbye                                           cb::const_byte_buffer,
362aacf24fdSTrond Norbye                                           size_t,
363aacf24fdSTrond Norbye                                           uint8_t,
364aacf24fdSTrond Norbye                                           uint64_t,
365aacf24fdSTrond Norbye                                           uint16_t,
366aacf24fdSTrond Norbye                                           uint64_t,
367aacf24fdSTrond Norbye                                           uint64_t,
368aacf24fdSTrond Norbye                                           cb::const_byte_buffer) {
369aacf24fdSTrond Norbye         return ENGINE_NO_BUCKET;
370aacf24fdSTrond Norbye     }
371aacf24fdSTrond Norbye 
dcp_deletion_v2(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * >,uint32_t,const DocKey &,cb::const_byte_buffer,size_t,uint8_t,uint64_t,uint16_t,uint64_t,uint64_t,uint32_t)37243afbf69SJim Walker     static ENGINE_ERROR_CODE dcp_deletion_v2(gsl::not_null<ENGINE_HANDLE*>,
37343afbf69SJim Walker                                              gsl::not_null<const void*>,
37443afbf69SJim Walker                                              uint32_t,
37543afbf69SJim Walker                                              const DocKey&,
37643afbf69SJim Walker                                              cb::const_byte_buffer,
37743afbf69SJim Walker                                              size_t,
37843afbf69SJim Walker                                              uint8_t,
37943afbf69SJim Walker                                              uint64_t,
38043afbf69SJim Walker                                              uint16_t,
38143afbf69SJim Walker                                              uint64_t,
38243afbf69SJim Walker                                              uint64_t,
38343afbf69SJim Walker                                              uint32_t) {
38443afbf69SJim Walker         return ENGINE_NO_BUCKET;
38543afbf69SJim Walker     }
38643afbf69SJim Walker 
dcp_expiration(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * >,uint32_t,const DocKey &,cb::const_byte_buffer,size_t,uint8_t,uint64_t,uint16_t,uint64_t,uint64_t,cb::const_byte_buffer)387aacf24fdSTrond Norbye     static ENGINE_ERROR_CODE dcp_expiration(gsl::not_null<ENGINE_HANDLE*>,
388aacf24fdSTrond Norbye                                             gsl::not_null<const void*>,
389aacf24fdSTrond Norbye                                             uint32_t,
390aacf24fdSTrond Norbye                                             const DocKey&,
391aacf24fdSTrond Norbye                                             cb::const_byte_buffer,
392aacf24fdSTrond Norbye                                             size_t,
393aacf24fdSTrond Norbye                                             uint8_t,
394aacf24fdSTrond Norbye                                             uint64_t,
395aacf24fdSTrond Norbye                                             uint16_t,
396aacf24fdSTrond Norbye                                             uint64_t,
397aacf24fdSTrond Norbye                                             uint64_t,
398aacf24fdSTrond Norbye                                             cb::const_byte_buffer) {
399aacf24fdSTrond Norbye         return ENGINE_NO_BUCKET;
400aacf24fdSTrond Norbye     }
401aacf24fdSTrond Norbye 
dcp_flush(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * >,uint32_t,uint16_t)402aacf24fdSTrond Norbye     static ENGINE_ERROR_CODE dcp_flush(gsl::not_null<ENGINE_HANDLE*>,
403aacf24fdSTrond Norbye                                        gsl::not_null<const void*>,
404aacf24fdSTrond Norbye                                        uint32_t,
405aacf24fdSTrond Norbye                                        uint16_t) {
406aacf24fdSTrond Norbye         return ENGINE_NO_BUCKET;
407aacf24fdSTrond Norbye     }
408aacf24fdSTrond Norbye 
dcp_set_vbucket_state(gsl::not_null<ENGINE_HANDLE * >,gsl::not_null<const void * >,uint32_t,uint16_t,vbucket_state_t)409aacf24fdSTrond Norbye     static ENGINE_ERROR_CODE dcp_set_vbucket_state(
410aacf24fdSTrond Norbye             gsl::not_null<ENGINE_HANDLE*>,
411aacf24fdSTrond Norbye             gsl::not_null<const void*>,
412aacf24fdSTrond Norbye             uint32_t,
413aacf24fdSTrond Norbye             uint16_t,
414447e01b9STrond Norbye             vbucket_state_t) {
415447e01b9STrond Norbye         return ENGINE_NO_BUCKET;
416447e01b9STrond Norbye     }
4170adf72a1SJim Walker 
dcp_system_event(gsl::not_null<ENGINE_HANDLE * > handle,gsl::not_null<const void * > cookie,uint32_t opaque,uint16_t vbucket,mcbp::systemevent::id event,uint64_t bySeqno,cb::const_byte_buffer key,cb::const_byte_buffer eventData)418aacf24fdSTrond Norbye     static ENGINE_ERROR_CODE dcp_system_event(
419aacf24fdSTrond Norbye             gsl::not_null<ENGINE_HANDLE*> handle,
420aacf24fdSTrond Norbye             gsl::not_null<const void*> cookie,
4210adf72a1SJim Walker             uint32_t opaque,
4220adf72a1SJim Walker             uint16_t vbucket,
4236ce93328SJim Walker             mcbp::systemevent::id event,
4240adf72a1SJim Walker             uint64_t bySeqno,
4250adf72a1SJim Walker             cb::const_byte_buffer key,
4260adf72a1SJim Walker             cb::const_byte_buffer eventData) {
4270adf72a1SJim Walker         return ENGINE_NO_BUCKET;
4280adf72a1SJim Walker     }
4297e325d3eSJim Walker 
collections_set_manifest(gsl::not_null<ENGINE_HANDLE * > handle,cb::const_char_buffer json)4307e325d3eSJim Walker     static cb::engine_error collections_set_manifest(
431aacf24fdSTrond Norbye             gsl::not_null<ENGINE_HANDLE*> handle, cb::const_char_buffer json) {
4327e325d3eSJim Walker         return {cb::engine_errc::no_bucket,
4337e325d3eSJim Walker                 "nobucket::collections_set_manifest"};
4347e325d3eSJim Walker     }
43586724888SJim Walker 
collections_get_manifest(gsl::not_null<ENGINE_HANDLE * > handle)436901d1ab8SJim Walker     static cb::EngineErrorStringPair collections_get_manifest(
437901d1ab8SJim Walker             gsl::not_null<ENGINE_HANDLE*> handle) {
438901d1ab8SJim Walker         return {cb::engine_errc::no_bucket,
439901d1ab8SJim Walker                 "nobucket::collections_get_manifest"};
440901d1ab8SJim Walker     }
441901d1ab8SJim Walker 
isXattrEnabled(gsl::not_null<ENGINE_HANDLE * > handle)442aacf24fdSTrond Norbye     static bool isXattrEnabled(gsl::not_null<ENGINE_HANDLE*> handle) {
44386724888SJim Walker         return false;
44486724888SJim Walker     }
44535cb14e6SSriram Ganesan 
getCompressionMode(gsl::not_null<ENGINE_HANDLE * > handle)44635cb14e6SSriram Ganesan     static BucketCompressionMode getCompressionMode(gsl::not_null<ENGINE_HANDLE*> handle) {
44735cb14e6SSriram Ganesan         return BucketCompressionMode::Off;
44835cb14e6SSriram Ganesan     }
449d92cc586SSriram Ganesan 
getMaxItemSize(gsl::not_null<ENGINE_HANDLE * > handle)450*1ed4a1e8SSriram Ganesan     static size_t getMaxItemSize(gsl::not_null<ENGINE_HANDLE*> handle) {
451*1ed4a1e8SSriram Ganesan         return default_max_item_size;
452*1ed4a1e8SSriram Ganesan     }
453*1ed4a1e8SSriram Ganesan 
getMinCompressionRatio(gsl::not_null<ENGINE_HANDLE * > handle)454d92cc586SSriram Ganesan     static float getMinCompressionRatio(gsl::not_null<ENGINE_HANDLE*> handle) {
455d92cc586SSriram Ganesan         return default_min_compression_ratio;
456d92cc586SSriram Ganesan     }
457447e01b9STrond Norbye };
458447e01b9STrond Norbye 
459447e01b9STrond Norbye MEMCACHED_PUBLIC_API
create_no_bucket_instance(uint64_t interface,GET_SERVER_API get_server_api,ENGINE_HANDLE ** handle)460447e01b9STrond Norbye ENGINE_ERROR_CODE create_no_bucket_instance(uint64_t interface,
461447e01b9STrond Norbye                                             GET_SERVER_API get_server_api,
462447e01b9STrond Norbye                                             ENGINE_HANDLE **handle)
463447e01b9STrond Norbye {
464447e01b9STrond Norbye     if (interface != 1) {
465447e01b9STrond Norbye         return ENGINE_ENOTSUP;
466447e01b9STrond Norbye     }
467447e01b9STrond Norbye 
468447e01b9STrond Norbye     try {
469447e01b9STrond Norbye         NoBucket* engine = new NoBucket();
470447e01b9STrond Norbye         *handle = reinterpret_cast<ENGINE_HANDLE*>(engine);
471447e01b9STrond Norbye     } catch (std::bad_alloc& e) {
472447e01b9STrond Norbye         auto logger = get_server_api()->log->get_logger();
473447e01b9STrond Norbye         logger->log(EXTENSION_LOG_WARNING, NULL,
474447e01b9STrond Norbye                     "NoBucket: failed to create engine: %s", e.what());
475447e01b9STrond Norbye         return ENGINE_FAILED;
476447e01b9STrond Norbye     }
477447e01b9STrond Norbye 
478447e01b9STrond Norbye     return ENGINE_SUCCESS;
479447e01b9STrond Norbye }
480447e01b9STrond Norbye 
481447e01b9STrond Norbye MEMCACHED_PUBLIC_API
destroy_engine(void)482447e01b9STrond Norbye void destroy_engine(void) {
483447e01b9STrond Norbye     // Empty
484447e01b9STrond Norbye }
485