A platform for high-performance distributed tool and library development written in C++. It can be deployed in two different cluster modes: standalone or distributed. API for v0.5.0, released on June 13, 2018.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CatalogStandardDatabaseMetadata.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * *
3  * Copyright 2018 Rice University *
4  * *
5  * Licensed under the Apache License, Version 2.0 (the "License"); *
6  * you may not use this file except in compliance with the License. *
7  * You may obtain a copy of the License at *
8  * *
9  * http://www.apache.org/licenses/LICENSE-2.0 *
10  * *
11  * Unless required by applicable law or agreed to in writing, software *
12  * distributed under the License is distributed on an "AS IS" BASIS, *
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14  * See the License for the specific language governing permissions and *
15  * limitations under the License. *
16  * *
17  *****************************************************************************/
18 /*
19  * CatalogStandardDatabaseMetadata.h
20  *
21  */
22 
23 #ifndef SRC_CATALOG_CATALOGSTANDARDDATABASEMETADATA_H_
24 #define SRC_CATALOG_CATALOGSTANDARDDATABASEMETADATA_H_
25 
26 #include <iostream>
27 #include <map>
28 #include <string>
29 #include <vector>
30 
31 #include "PDBDebug.h"
33 
34 using namespace std;
35 
36 // This class serves to store information about the databases in a given
37 // instance of PDB
38 // and provide methods for maintaining their associated metadata.
39 // Clients of this class will access this information using a handler to the
40 // catalog.
41 
43 public:
45 
46  CatalogStandardDatabaseMetadata(string dbIdIn, string dbNameIn,
47  string userCreatorIn, string createdOnIn,
48  string lastModifiedIn);
49 
51  const CatalogStandardDatabaseMetadata &pdbDatabaseToCopy);
52 
53  void setValues(string dbIdIn, string dbNameIn, string userCreatorIn,
54  string createdOnIn, string lastModifiedIn);
55 
57 
58  void addPermission(CatalogStandardPermissionsMetadata &permissionsIn);
59 
60  void addNode(string &nodeIn);
61 
62  void addSet(string &setIn);
63 
64  void addSetToMap(string &setName, string &nodeIP);
65 
66  void addNodeToMap(string &nodeIP, string &setName);
67 
68  void addType(string &typeIn);
69 
70  void replaceListOfSets(vector<string> &newList);
71 
72  void replaceListOfNodes(vector<string> &newList);
73 
74  void replaceMapOfSets(map<string, vector<string>> &newMap);
75 
76  void replaceMapOfNodes(map<string, vector<string>> &newMap);
77 
83  void deleteSet(string setName);
84 
85  void removeNodeFromSet(string node, string set);
86 
87  void deleteNodeFromMap(string &nodeIP, string &setName);
88 
89  void deleteType(string &typeIn);
90 
91  vector<string> getListOfNodes();
92 
93  vector<string> getListOfSets();
94 
95  vector<string> getListOfTypes();
96 
97  vector<CatalogStandardPermissionsMetadata> getListOfPermissions();
98 
99  string getItemId();
100 
101  string getItemName();
102 
103  string getItemKey();
104 
105  string getUserCreator();
106 
107  string getCreatedOn();
108 
109  string getLastModified();
110 
111  void setItemKey(string &itemKeyIn);
112 
113  void setItemId(string &idIn);
114 
115  void setItemName(string &itemNameIn);
116 
117  map<string, vector<string>> getSetsInDB();
118 
119  map<string, vector<string>> getNodesInDB();
120 
121  string printShort();
122 
123  friend std::ostream &operator<<(std::ostream &out,
125  out << "\nCatalog Database Metadata" << endl;
126  out << "-------------------" << endl;
127  out << " DB Id: " << database.getItemId().c_str() << endl;
128  out << " DB Key: " << database.getItemKey().c_str() << endl;
129  out << " DB Name: " << database.getItemName().c_str() << endl;
130  out << "\nThis Database is stored in the following nodes: " << endl;
131  for (int i = 0; i < database.getListOfNodes().size(); i++) {
132  // out << " IP: " << database.getListOfNodes().[i] << endl;
133  }
134  out << "\nThis Database has the following sets: " << endl;
135  for (int i = 0; i < database.getListOfSets().size(); i++) {
136  out << " Set: " << database.getListOfSets()[i].c_str() << endl;
137  }
138 
139  out << "-------------------\n" << endl;
140  return out;
141  }
142 
143 private:
144  string dbId;
145  string dbName;
146  string userCreator;
147  string createdOn;
148  string lastModified;
149 
150  // a map where the key is the name of a set and the value is a vector with
151  // all nodes where that set has information stored
152  map<string, vector<string>> setsInDB;
153 
154  // a map where the key is the IP of a node and the value is a vector with
155  // all sets in that node that contain data for this database
156  map<string, vector<string>> nodesInDB;
157 
158  // Contains information about nodes in the cluster with data for a given
159  // database
160  vector<string> listOfNodes;
161 
162  // Contains information about sets in the cluster containing data for a given
163  // database
164  // this might change, check with Jia if this is needed or not
165  vector<string> listOfSets;
166 
167  // Contains information about types in the cluster containing data for a given
168  // database
169  // this might change, check with Jia if this is needed or not
170  vector<string> listOfTypes;
171 
172  // Contains all users' permissions for a given database
173  vector<CatalogStandardPermissionsMetadata> listOfPermissions;
174 
175  void deleteSetFromSetList(string &setName);
176 
177  void deleteSetFromSetMap(string &setName);
178 
179  void deleteNodeFromSingleSet(string &node, string &setName);
180 
181  void deleteSetFromSingleNode(string &setName, string &node);
182 
183  void deleteSetFromNodeMap(string &setName);
184 };
185 
186 #endif /* SRC_CATALOG_CATALOGSTANDARDDATABASEMETADATA_H_ */
vector< CatalogStandardPermissionsMetadata > listOfPermissions
map< string, vector< string > > nodesInDB
map< string, vector< string > > setsInDB
friend std::ostream & operator<<(std::ostream &out, CatalogStandardDatabaseMetadata &database)