1/**
2 * Copyright 2021 Alibaba, Inc. and its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * \author guonix
17 * \date Oct 2020
18 * \brief
19 */
20
21#pragma once
22
23#include "common/interface/service.h"
24#include "meta.h"
25
26namespace proxima {
27namespace be {
28namespace meta {
29
30//! Predefined class
31class MetaService;
32//! MetaStore Alias
33using MetaServicePtr = std::shared_ptr<MetaService>;
34
35
36/*!
37 * MetaService implementation
38 */
39class MetaService : public Service {
40 public:
41 // Destructor
42 ~MetaService() override = default;
43
44 public:
45 //! Reload meta service
46 virtual int reload() = 0;
47
48 //! Create collection and columns
49 virtual int create_collection(const CollectionBase &param,
50 CollectionMetaPtr *collection) = 0;
51
52 //! Update collection and columns, increase revision and copy a new collection
53 virtual int update_collection(const CollectionBase &param,
54 CollectionMetaPtr *collection) = 0;
55
56 //! Enable collection
57 virtual int enable_collection(const std::string &collection,
58 uint32_t revision, bool enable) = 0;
59
60 //! Update the status of current used collection
61 virtual int update_status(const std::string &collection_name,
62 CollectionStatus status) = 0;
63
64 //! Suspend reading requests of collection
65 virtual int suspend_collection_read(const std::string &collection_name) = 0;
66
67 //! Resume reading requests of collection
68 virtual int resume_collection_read(const std::string &collection_name) = 0;
69
70 //! Suspend writing requests of collection
71 virtual int suspend_collection_write(const std::string &collection_name) = 0;
72
73 //! Resume writing requests of collection
74 virtual int resume_collection_write(const std::string &collection_name) = 0;
75
76 //! Drop collection
77 virtual int drop_collection(const std::string &name) = 0;
78
79 //! Retrieve latest version of collection
80 virtual CollectionMetaPtr get_current_collection(
81 const std::string &name) const = 0;
82
83 //! Retrieve latest version of collections
84 virtual int get_latest_collections(
85 CollectionMetaPtrList *collections) const = 0;
86
87 //! Retrieve all of collections
88 virtual int get_collections(CollectionMetaPtrList *collections) const = 0;
89
90 //! Retrieve collections with specific repository
91 virtual int get_collections_by_repo(
92 const std::string &repository,
93 CollectionMetaPtrList *collections) const = 0;
94
95 //! Retrieve collections with specific collection name
96 virtual int get_collections(const std::string &collection,
97 CollectionMetaPtrList *collections) const = 0;
98
99 //! Retrieve collection
100 virtual CollectionMetaPtr get_collection(const std::string &collection,
101 uint64_t revision) const = 0;
102
103 //! Check collection exists
104 virtual bool exist_collection(const std::string &collection) const = 0;
105
106}; // end of MetaService
107
108
109} // namespace meta
110} // namespace be
111} // namespace proxima
112