0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
StateDbKeys.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
22 #include "Common/Compat.h"
23 #include "Common/String.h"
24 #include "Common/StringExt.h"
25 #include "Common/Logger.h"
26 
27 #include "StateDbKeys.h"
28 
29 using namespace Hyperspace;
30 using namespace Hypertable;
31 using namespace Error;
32 
33 namespace Hyperspace {
34 namespace StateDbKeys {
35 
36  String get_event_key(uint64_t id, uint32_t type) {
37 
38  String key = EVENTS_STR + id + PATH_DELIM_STR;
39  switch(type) {
40  case(EVENT_TYPE):
41  key += EVENT_TYPE_STR;
42  break;
43  case(EVENT_MASK):
44  key += EVENT_MASK_STR;
45  break;
48  break;
49  case(EVENT_NAME):
50  key += EVENT_NAME_STR;
51  break;
52  case(EVENT_MODE):
53  key += EVENT_MODE_STR;
54  break;
55  case(EVENT_GENERATION):
56  key += EVENT_GENERATION_STR;
57  break;
58  default:
60  }
61  return key;
62  }
63 
64  String get_session_key(uint64_t id, uint32_t type) {
65 
66  String key = SESSIONS_STR + id + PATH_DELIM_STR;
67  switch(type) {
68  case (SESSION_EXPIRED):
69  key += SESSION_EXPIRED_STR;
70  break;
71  case(SESSION_ADDR):
72  key += SESSION_ADDR_STR;
73  break;
74  case(SESSION_HANDLES):
75  key += SESSION_HANDLES_STR;
76  break;
77  case(SESSION_NAME):
78  key += SESSION_NAME_STR;
79  break;
80  default:
82  }
83  return key;
84  }
85 
86  String get_handle_key(uint64_t id, uint32_t type) {
87 
88  String key = HANDLES_STR + id + PATH_DELIM_STR;
89  switch(type) {
90  case (HANDLE_OPEN_FLAGS):
91  key += HANDLE_OPEN_FLAGS_STR;
92  break;
93  case(HANDLE_DEL_STATE):
94  key += HANDLE_DEL_STATE_STR;
95  break;
96  case(HANDLE_EVENT_MASK):
97  key += HANDLE_EVENT_MASK_STR;
98  break;
99  case(HANDLE_LOCKED):
100  key += HANDLE_LOCKED_STR;
101  break;
102  case(HANDLE_NODE_NAME):
103  key += HANDLE_NODE_NAME_STR;
104  break;
105  case(HANDLE_SESSION_ID):
106  key += HANDLE_SESSION_ID_STR;
107  break;
108  default:
110  }
111  return key;
112  }
113 
114  String get_node_key(const String &name, uint32_t type) {
115 
116  String key = NODES_STR + name + PATH_DELIM_STR;
117  switch(type) {
118  case(NODE_NAME):
119  break;
120  case (NODE_EPHEMERAL):
121  key += NODE_EPHEMERAL_STR;
122  break;
123  case(NODE_LOCK_GENERATION):
125  break;
126  case(NODE_LOCK_MODE):
127  key += NODE_LOCK_MODE_STR;
128  break;
131  break;
134  break;
137  break;
138  case(NODE_HANDLE_MAP):
139  key += NODE_HANDLE_MAP_STR;
140  break;
141  case(NODE_HANDLE_MAP_SIZE):
143  break;
144 
145  default:
147  }
148  return key;
149 
150  }
151 
152  String get_node_pending_lock_request_key(const String &name, uint64_t handle_id)
153  {
155  key = key + handle_id;
156  return key;
157  }
158 
159 } //namespace StateDbKeys
160 } //namespace Hyperspace
161 
162 
const String HANDLE_DEL_STATE_STR
Definition: StateDbKeys.h:93
const String EVENT_GENERATION_STR
Definition: StateDbKeys.h:127
const String SESSION_HANDLES_STR
Definition: StateDbKeys.h:105
const String NODE_SHARED_LOCK_HANDLES_STR
Definition: StateDbKeys.h:116
const String HANDLE_EVENT_MASK_STR
Definition: StateDbKeys.h:94
const String SESSION_ADDR_STR
Definition: StateDbKeys.h:103
String get_event_key(uint64_t id, uint32_t type)
Definition: StateDbKeys.cc:36
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
const String PATH_DELIM_STR
Definition: StateDbKeys.h:88
String get_session_key(uint64_t id, uint32_t type)
Definition: StateDbKeys.cc:64
const String EVENTS_STR
Definition: StateDbKeys.h:122
const String EVENT_NAME_STR
Definition: StateDbKeys.h:125
const String SESSIONS_STR
Definition: StateDbKeys.h:100
const String NODE_PENDING_LOCK_REQUESTS_STR
Definition: StateDbKeys.h:117
const String SESSION_NAME_STR
Definition: StateDbKeys.h:107
const String NODES_STR
Definition: StateDbKeys.h:109
Hyperspace definitions
#define HT_EXPECT(_e_, _code_)
Definition: Logger.h:388
const String EVENT_NOTIFICATION_HANDLES_STR
Definition: StateDbKeys.h:128
const String HANDLE_SESSION_ID_STR
Definition: StateDbKeys.h:97
const String NODE_HANDLE_MAP_SIZE_STR
Definition: StateDbKeys.h:119
const String NODE_EPHEMERAL_STR
Definition: StateDbKeys.h:112
Logging routines and macros.
Compatibility Macros for C/C++.
const String HANDLE_NODE_NAME_STR
Definition: StateDbKeys.h:96
const String NODE_EXCLUSIVE_LOCK_HANDLE_STR
Definition: StateDbKeys.h:115
const String EVENT_TYPE_STR
Definition: StateDbKeys.h:123
const String EVENT_MODE_STR
Definition: StateDbKeys.h:126
Hypertable definitions
const String HANDLE_OPEN_FLAGS_STR
Definition: StateDbKeys.h:92
const String HANDLES_STR
Definition: StateDbKeys.h:90
A String class based on std::string.
const String HANDLE_LOCKED_STR
Definition: StateDbKeys.h:95
const String NODE_LOCK_GENERATION_STR
Definition: StateDbKeys.h:114
String get_handle_key(uint64_t id, uint32_t type)
Definition: StateDbKeys.cc:86
const String NODE_LOCK_MODE_STR
Definition: StateDbKeys.h:113
const String SESSION_EXPIRED_STR
Definition: StateDbKeys.h:104
const String EVENT_MASK_STR
Definition: StateDbKeys.h:124
String get_node_pending_lock_request_key(const String &name, uint64_t handle_id)
Definition: StateDbKeys.cc:152
String extensions and helpers: sets, maps, append operators etc.
String get_node_key(const String &name, uint32_t type)
Definition: StateDbKeys.cc:114
const String NODE_HANDLE_MAP_STR
Definition: StateDbKeys.h:118