36 #include <boost/algorithm/string.hpp>
37 #include <boost/filesystem.hpp>
48 using namespace Error;
51 #define HT_DEBUG_ATTR(_txn_, _fn_, _an_, _k_, _v_) \
52 HT_DEBUG_OUT <<"txn="<< (_txn_) <<" fname='"<< (_fn_) <<"' attr='"<< (_an_) \
53 <<"' key='"<< (char *)(_k_).get_data() <<"' value='"<< (_v_) <<"'" \
56 #define HT_DEBUG_ATTR_(_txn_, _fn_, _an_, _k_, _v_, _l_) \
57 HT_DEBUG_OUT <<"txn="<< (_txn_) <<" fname='"<< (_fn_); \
58 if ((_an_) == String()) _out_ <<"' attr='"<< (_an_); \
59 _out_ <<"' key='" << (char *)(_k_).get_data(); \
60 if (_l_) _out_ <<"' value='"<< format_bytes(20, _v_, _l_); \
70 const char* BerkeleyDbFilesystem::ms_name_namespace_db =
"namespace.db";
71 const char* BerkeleyDbFilesystem::ms_name_state_db =
"state.db";
74 const std::string &basedir,
75 const std::vector<Thread::id> &thread_ids,
77 : m_base_dir(basedir), m_env(0) {
81 m_log_gc_interval = std::chrono::milliseconds(props->get_i32(
"Hyperspace.LogGc.Interval"));
95 env_flags |= DB_RECOVER_FATAL;
97 m_db_flags = DB_CREATE | DB_AUTO_COMMIT | DB_THREAD;
109 HT_INFOF(
"localhost=%s localip=%s", localhost.c_str(), localip.c_str());
111 m_env.set_lk_detect(DB_LOCK_DEFAULT);
116 m_env.set_verbose(DB_VERB_REPLICATION, 1);
124 Db old_state_db(&
m_env, 0);
125 old_state_db.remove(ms_name_state_db, NULL, 0);
135 if (props->has(
"Hyperspace.Replica.Host"))
140 int replication_port = props->get_i16(
"Hyperspace.Replica.Replication.Port");
142 size_t localhost_len = localhost.find(
'.');
143 if (localhost_len == std::string::npos)
144 localhost_len = localhost.length();
145 localhost = localhost.substr(0, localhost_len);
148 m_env.rep_set_config(DB_REP_CONF_LEASE, 1);
150 m_env.rep_set_config(DB_REP_CONF_BULK, 1);
153 m_env.rep_set_config(DB_REPMGR_CONF_2SITE_STRICT, 1);
155 m_env.repmgr_set_ack_policy(DB_REPMGR_ACKS_QUORUM);
157 #if !(DB_VERSION_MAJOR > 5 || (DB_VERSION_MAJOR == 5 && DB_VERSION_MINOR >= 2))
162 m_env.rep_set_timeout(DB_REP_HEARTBEAT_SEND, 30000000);
163 m_env.rep_set_timeout(DB_REP_HEARTBEAT_MONITOR, 60000000);
164 m_env.rep_set_timeout(DB_REP_ACK_TIMEOUT,
165 props->get_i32(
"Hyperspace.Replica.Replication.Timeout")*1000);
166 m_env.rep_set_timeout(DB_REP_CONNECTION_RETRY, 5000000);
167 m_env.rep_set_timeout(DB_REP_LEASE_TIMEOUT,
168 props->get_i32(
"Hyperspace.Replica.Replication.Timeout")*1000);
171 for (
auto replica : props->get_strs(
"Hyperspace.Replica.Host")) {
173 bool is_localhost=
false;
178 if (replica == localip)
182 size_t replica_len = replica.find(
'.');
183 if (replica_len == std::string::npos)
184 replica_len = replica.length();
185 replica = replica.substr(0, replica_len);
187 if (boost::iequals(localhost, e.
host))
192 m_env.rep_set_priority(priority);
194 #if DB_VERSION_MAJOR > 5 || (DB_VERSION_MAJOR == 5 && DB_VERSION_MINOR >= 2)
197 dbsite->set_config(DB_LOCAL_SITE, 1);
198 dbsite->set_config(DB_LEGACY, 1);
204 HT_INFOF(
"Added local replication site %s priority=%d", e.
host.c_str(), priority);
209 #if DB_VERSION_MAJOR > 5 || (DB_VERSION_MAJOR == 5 && DB_VERSION_MINOR >= 2)
212 dbsite->set_config(DB_BOOTSTRAP_HELPER, 1);
213 dbsite->set_config(DB_LEGACY, 1);
214 dbsite->get_eid(&eid);
217 m_env.repmgr_add_remote_site(e.
host.c_str(), e.
port, &eid, 0);
220 HT_INFOF(
"Added remote replication site %s priority=%d", e.
host.c_str(), priority);
224 m_env.repmgr_start(3, DB_REP_ELECTION);
236 m_env.txn_checkpoint(0, 0, 0);
239 Db *handle_namespace_db =
new Db(&
m_env, 0);
240 Db *handle_state_db =
new Db(&
m_env, 0);
245 catch(DbException &e) {
247 if (e.get_errno() == DB_LOCK_DEADLOCK)
253 handle_state_db->set_flags(DB_DUP|DB_REVSPLITOFF);
257 catch(DbException &e) {
259 if (e.get_errno() == DB_LOCK_DEADLOCK)
265 key.set_data((
void *)
"/");
268 data.set_flags(DB_DBT_REALLOC);
269 if ((ret = handle_namespace_db->get(NULL, &key, &data, 0)) == DB_NOTFOUND) {
272 ret = handle_namespace_db->put(NULL, &key, &data, 0);
273 key.set_data((
void *)
"/hyperspace/");
274 key.set_size(strlen(
"/hyperspace/")+1);
275 ret = handle_namespace_db->put(NULL, &key, &data, 0);
276 key.set_data((
void *)
"/hyperspace/metadata");
277 key.set_size(strlen(
"/hyperspace/metadata")+1);
278 ret = handle_namespace_db->put(NULL, &key, &data, 0);
281 if (data.get_data() != 0)
282 free(data.get_data());
285 key.set_data((
void *)
"/");
288 data.set_flags(DB_DBT_REALLOC);
292 if((ret = handle_state_db->get(NULL, &key, &data, 0)) == DB_NOTFOUND) {
295 ret = handle_state_db->put(NULL, &key, &data, 0);
300 if ((ret = handle_state_db->get(NULL, &keym, &datam, 0)) == DB_NOTFOUND) {
301 sprintf(numbuf,
"%llu", (
Llu)1);
303 ret = handle_state_db->put(NULL, &keym, &datam, 0);
307 if ( (ret = handle_state_db->get(NULL, &keym, &datam, 0)) == DB_NOTFOUND) {
308 sprintf(numbuf,
"%llu", (
Llu)1);
310 ret = handle_state_db->put(NULL, &keym, &datam, 0);
314 if ((ret = handle_state_db->get(NULL, &keym, &datam, 0)) == DB_NOTFOUND) {
315 sprintf(numbuf,
"%llu", (
Llu)1);
317 ret = handle_state_db->put(NULL, &keym, &datam, 0);
321 if (data.get_data() != 0)
322 free(data.get_data());
325 handle_state_db->close(0);
326 delete handle_state_db;
328 handle_namespace_db->close(0);
329 delete handle_namespace_db;
330 handle_namespace_db = 0;
331 HT_INFO(
"Replication master init done");
335 catch (DbException &e) {
337 DB_REPMGR_SITE *list = 0;
338 if (
m_env.repmgr_site_list(&count, &list) == 0) {
341 msg =
String(
"The following replicas are (dis)connected: ");
342 for (
unsigned i = 0; i < count; i++) {
343 const char *
status =
"unknown";
344 switch (list[i].status) {
345 case DB_REPMGR_CONNECTED:
346 status =
"connected";
348 case DB_REPMGR_DISCONNECTED:
349 status =
"disconnected";
352 msg +=
String(
"(") + list[i].host +
" status: " +
status;
357 HT_FATALF(
"Error initializing Berkeley DB (dir=%s) - %s; please make sure "
358 "that the hyperspace replicas are correctly configured.",
374 HT_INFO(
"Closed DB handles for all threads ");
376 (val.second)->close();
380 catch(DbException &e) {
381 HT_ERRORF(
"Error closing Berkeley DB (dir=%s) - %s",
404 case DB_EVENT_REP_CLIENT:
405 HT_INFO(
"Received DB_EVENT_REP_CLIENT event");
407 case DB_EVENT_REP_MASTER:
408 HT_INFO(
"Received DB_EVENT_REP_MASTER event");
413 case DB_EVENT_REP_ELECTED:
414 HT_INFO(
"Received DB_EVENT_REP_ELECTED event ignore and wait for DB_EVENT_REP_MASTER");
416 case DB_EVENT_REP_NEWMASTER:
417 HT_INFO(
"Received DB_EVENT_REP_NEWMASTER event");
420 HT_FATAL(
"Local site lost mastership");
425 HT_INFOF(
"New master elected: %s", it->second.c_str());
428 HT_FATAL(
"New master elected after initial master election.");
433 case DB_EVENT_REP_PERM_FAILED:
435 HT_FATAL(
"Replication failed. Master did not receive enough acks.");
438 HT_FATAL(
"Received DB_EVENT_PANIC event");
440 case DB_EVENT_REP_STARTUPDONE:
441 HT_INFO(
"Received DB_EVENT_REP_STARTUPDONE event");
443 case DB_EVENT_WRITE_FAILED:
444 HT_INFO(
"Received DB_EVENT_WROTE_FAILED event");
447 #if DB_VERSION_MAJOR > 5 || (DB_VERSION_MAJOR == 5 && DB_VERSION_MINOR >= 2)
448 case DB_EVENT_REP_CONNECT_BROKEN:
449 HT_INFO(
"Received DB_EVENT_REP_CONNECT_BROKEN event");
451 case DB_EVENT_REP_CONNECT_ESTD:
452 HT_INFO(
"Received DB_EVENT_REP_CONNECT_ESTD event");
454 case DB_EVENT_REP_CONNECT_TRY_FAILED:
455 HT_INFO(
"Received DB_EVENT_REP_CONNECT_TRY_FAILED event");
457 case DB_EVENT_REP_DUPMASTER:
458 HT_INFO(
"Received DB_EVENT_REP_DUPMASTER event");
460 case DB_EVENT_REP_ELECTION_FAILED:
461 HT_INFO(
"Received DB_EVENT_REP_ELECTION_FAILED event");
463 case DB_EVENT_REP_INIT_DONE:
464 HT_INFO(
"Received DB_EVENT_REP_INIT_DONE event");
466 case DB_EVENT_REP_JOIN_FAILURE:
467 HT_INFO(
"Received DB_EVENT_REP_JOIN_FAILURE event");
469 case DB_EVENT_REP_LOCAL_SITE_REMOVED:
470 HT_INFO(
"Received DB_EVENT_REP_LOCAL_SITE_REMOVED event");
472 case DB_EVENT_REP_MASTER_FAILURE:
473 HT_INFO(
"Received DB_EVENT_REP_MASTER_FAILURE event");
475 case DB_EVENT_REP_SITE_ADDED:
476 HT_INFO(
"Received DB_EVENT_REP_SITE_ADDED event");
478 case DB_EVENT_REP_SITE_REMOVED:
479 HT_INFO(
"Received DB_EVENT_REP_SITE_REMOVED event");
484 HT_INFO(
"Received BerkeleyDB event ");
493 std::stringstream tid_str;
494 for (
auto thread_id : thread_ids) {
495 db_handles = std::make_shared<BDbHandles>();
497 tid_str << thread_id;
498 HT_INFOF(
"Created DB handles for thread: %s", tid_str.str().c_str());
499 tid_str.str(std::string());
508 HT_FATAL_OUT <<
"No thread handle found for thread " << ThisThread::get_id() <<
HT_END;
511 if (!it->second->open) {
512 it->second->handle_namespace_db =
new Db(&
m_env, 0);
513 it->second->handle_state_db =
new Db(&
m_env, 0);
516 it->second->handle_state_db->set_flags(DB_DUP|DB_REVSPLITOFF);
519 it->second->open=
true;
537 catch (DbException &e) {
541 auto now = std::chrono::steady_clock::now();
545 m_last_log_gc_time = now;
548 char **unused_logs, **log;
549 uint32_t unused_logs_count=0;
550 unused_logs = log = NULL;
553 ret =
m_env.log_archive(&unused_logs, DB_ARCH_ABS);
555 HT_FATAL_OUT <<
"Unable to get list of unused BerkeleyDB log files, got ret=" << ret
559 catch (DbException &e) {
560 HT_FATAL_OUT<<
"Error getting list of unused BerkeleyDb log files: "
565 if (unused_logs != NULL) {
566 for (log = unused_logs; *log != NULL; ++log)
570 ++log, --unused_logs_count) {
573 boost::filesystem::remove(file);
574 HT_INFOF(
"Deleted unused BerkeleyDb log %s", *log);
598 catch (DbException &e) {
613 const String &aname, uint32_t *valuep) {
623 *valuep = strtoll((
const char *)data.get_data(), 0, 0);
628 catch (DbException &e) {
629 if (e.get_errno() == DB_LOCK_DEADLOCK)
631 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
633 HT_ERRORF(
"Berkeley DB error: %s", e.what());
646 const String &aname, uint32_t value) {
654 sprintf(numbuf,
"%u", value);
656 data.set_data(numbuf);
657 data.set_size(strlen(numbuf)+1);
663 catch (DbException &e) {
664 if (e.get_errno() == DB_LOCK_DEADLOCK)
666 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
668 HT_ERRORF(
"Berkeley DB error: %s", e.what());
680 const String &aname, uint64_t *valuep) {
690 *valuep = strtoll((
const char *)data.get_data(), 0, 0);
695 catch (DbException &e) {
696 if (e.get_errno() == DB_LOCK_DEADLOCK)
698 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
700 HT_ERRORF(
"Berkeley DB error: %s", e.what());
713 const String &aname, uint64_t value) {
721 sprintf(numbuf,
"%llu", (
Llu)value);
723 data.set_data(numbuf);
724 data.set_size(strlen(numbuf)+1);
730 catch (DbException &e) {
731 if (e.get_errno() == DB_LOCK_DEADLOCK)
733 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
735 HT_ERRORF(
"Berkeley DB error: %s", e.what());
756 data.set_flags(DB_DBT_REALLOC);
758 if (data.get_size() >= 24)
760 "incr attribute '%s' exceeds 24 characters", aname.c_str());
762 memcpy(numbuf, (
const char *)data.get_data(), data.get_size());
763 numbuf[data.get_size()] = 0;
766 for (
const char *ptr=numbuf; *ptr; ptr++) {
767 if (!::isdigit(*ptr))
769 "incr attribute '%s' contains invalid characters: %s",
770 aname.c_str(), numbuf);
773 *valuep = strtoull(numbuf, 0, 0);
776 if (*valuep == 0 && errno == EINVAL)
778 "incr attr '%s' invalid: '%s', cannot convert to integer",
779 aname.c_str(), numbuf);
782 new_value = *valuep + 1;
783 sprintf(numbuf,
"%llu", (
Llu)new_value);
784 data.set_data(numbuf);
785 data.set_size(strlen(numbuf));
793 catch (DbException &e) {
794 if (e.get_errno() == DB_LOCK_DEADLOCK)
796 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
798 HT_ERRORF(
"Berkeley DB error: %s", e.what());
808 const String &aname,
const void *value,
size_t value_len) {
814 data.set_data((
void *)value);
815 data.set_size(value_len);
821 catch (DbException &e) {
822 if (e.get_errno() == DB_LOCK_DEADLOCK)
824 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
826 HT_ERRORF(
"Berkeley DB error: %s", e.what());
846 HT_DEBUG_OUT <<
"get_xattr txn="<< txn <<
", fname=" << fname <<
", attr='" << aname <<
HT_END;
851 memcpy(vbuf.
base, (uint8_t *)data.get_data(), data.get_size());
852 vbuf.
ptr += data.get_size();
857 catch (DbException &e) {
858 if (e.get_errno() == DB_LOCK_DEADLOCK)
860 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
862 HT_ERRORF(
"Berkeley DB error: %s", e.what());
889 catch (DbException &e) {
890 if (e.get_errno() == DB_LOCK_DEADLOCK)
892 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
894 HT_ERRORF(
"Berkeley DB error: %s", e.what());
916 catch (DbException &e) {
917 if (e.get_errno() == DB_LOCK_DEADLOCK)
919 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
921 HT_ERRORF(
"Berkeley DB error: %s", e.what());
933 size_t lastslash = name.rfind(
'/', name.length()-1);
934 String dirname = name.substr(0, lastslash+1);
940 key.set_data((
void *)dirname.c_str());
941 key.set_size(dirname.length()+1);
948 if (dirname[dirname.length()-1] !=
'/')
956 key.set_data((
void *)dirname.c_str());
957 key.set_size(dirname.length()+1);
965 key.set_data((
void *)dirname.c_str());
966 key.set_size(dirname.length()+1);
973 catch (DbException &e) {
974 if (e.get_errno() == DB_LOCK_DEADLOCK)
976 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
978 HT_ERRORF(
"Berkeley DB error: %s", e.what());
985 std::vector<String> delkeys;
990 bool looks_like_dir =
false;
991 bool looks_like_file =
false;
999 if (cursorp->get(&keym, &datam, DB_SET_RANGE) != DB_NOTFOUND) {
1003 if (str.length() > name.length()) {
1004 if (str[name.length()] ==
'/') {
1005 if (str.length() > name.length() + 1
1009 looks_like_dir =
true;
1010 delkeys.push_back(keym.
get_str());
1013 looks_like_file =
true;
1014 delkeys.push_back(keym.
get_str());
1018 delkeys.push_back(keym.
get_str());
1019 looks_like_file =
true;
1022 }
while (cursorp->get(&keym, &datam, DB_NEXT) != DB_NOTFOUND &&
1023 starts_with(keym.
get_str(), name.c_str()));
1026 HT_ASSERT(!(looks_like_dir && looks_like_file));
1028 if (delkeys.empty())
1031 for (
size_t i=0; i<delkeys.size(); i++) {
1032 key.set_data((
void *)delkeys[i].c_str());
1033 key.set_size(delkeys[i].length()+1);
1038 catch (DbException &e) {
1039 HT_ERRORF(
"Berkeley DB error: %s", e.what());
1040 if (e.get_errno() == DB_LOCK_DEADLOCK)
1042 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
1058 key.set_data((
void *)fname.c_str());
1059 key.set_size(fname.length()+1);
1064 key.set_data((
void *)fname.c_str());
1065 key.set_size(fname.length()+1);
1075 catch (DbException &e) {
1076 HT_ERRORF(
"Berkeley DB error: %s", e.what());
1077 if (e.get_errno() == DB_LOCK_DEADLOCK)
1079 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
1102 if (
exists(txn, fname, 0))
1105 if (ends_with(fname,
"/"))
1108 size_t lastslash = fname.rfind(
'/', fname.length() - 1);
1109 String parent_dir = fname.substr(0, lastslash + 1);
1111 key.set_data((
void *)parent_dir.c_str());
1112 key.set_size(parent_dir.length()+1);
1117 key.set_data((
void *)fname.c_str());
1118 key.set_size(fname.length()+1);
1124 key.set_data((
void *)temp_key.c_str());
1125 key.set_size(temp_key.length()+1);
1129 catch (DbException &e) {
1130 HT_ERRORF(
"Berkeley DB error: %s", e.what());
1131 if (e.get_errno() == DB_LOCK_DEADLOCK)
1133 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
1143 std::vector<DirEntry> &listing) {
1155 if (!ends_with(fname,
"/"))
1161 if (cursorp->get(&keym, &datam, DB_SET_RANGE) != DB_NOTFOUND) {
1163 if (!starts_with(keym.
get_str(), fname.c_str())) {
1170 if (str.length() > fname.length()) {
1172 str = str.substr(fname.length());
1174 if ((offset = str.find(
'/')) != String::npos) {
1175 entry.
name = str.substr(0, offset);
1177 if (entry.
name != last_str) {
1179 listing.push_back(entry);
1180 last_str = entry.
name;
1185 entry.
name = str.substr(0, offset);
1187 if (entry.
name != last_str) {
1189 listing.push_back(entry);
1190 last_str = entry.
name;
1196 if (entry.
name != last_str) {
1198 listing.push_back(entry);
1199 last_str = entry.
name;
1205 }
while (cursorp->get(&keym, &datam, DB_NEXT) != DB_NOTFOUND &&
1206 starts_with(keym.
get_str(), fname.c_str()));
1210 catch (DbException &e) {
1211 if (e.get_errno() == DB_LOCK_DEADLOCK)
1213 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
1215 HT_ERRORF(
"Berkeley DB error: %s", e.what());
1227 bool include_sub_entries,
1228 std::vector<DirEntryAttr> &listing) {
1230 if (include_sub_entries) {
1231 if (!ends_with(fname,
"/"))
1233 for (
auto &entry : listing)
1242 std::vector<DirEntryAttr> &listing) {
1247 String entryname, last_entryname,
str, attr;
1254 if (!ends_with(fname,
"/"))
1260 if (cursorp->get(&keym, &datam, DB_SET_RANGE) != DB_NOTFOUND) {
1262 if (!starts_with(keym.
get_str(), fname.c_str())) {
1269 if (str.length() > fname.length() && str[fname.length()] !=
NODE_ATTR_DELIM) {
1270 str = str.substr(fname.length());
1271 offset = str.find_first_of(stop_chars);
1272 entryname = (offset == String::npos) ? str : str.substr(0, offset);
1273 if (entryname != last_entryname) {
1274 if (last_entryname !=
"")
1275 listing.push_back(entry);
1276 last_entryname = entryname;
1278 entry.
name = entryname;
1283 if (offset != String::npos) {
1284 if (str[offset] ==
'/') {
1287 attr = str.substr(offset+2);
1289 if (attr == aname) {
1292 entry.
attr = buffer;
1298 attr = str.substr(offset+1);
1299 if (attr == aname) {
1302 entry.
attr = buffer;
1309 }
while (cursorp->get(&keym, &datam, DB_NEXT) != DB_NOTFOUND &&
1310 starts_with(keym.
get_str(), fname.c_str()));
1312 if (last_entryname !=
"")
1313 listing.push_back(entry);
1317 catch (DbException &e) {
1318 if (e.get_errno() == DB_LOCK_DEADLOCK)
1320 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
1322 HT_ERRORF(
"Berkeley DB error: %s", e.what());
1329 std::vector<String> &names) {
1340 while ((ret = cursorp->get(&keym, &datam, DB_NEXT)) == 0) {
1341 names.push_back(keym.
get_str());
1344 catch(DbException &e) {
1345 if (e.get_errno() == DB_REP_HANDLE_DEAD)
1348 HT_FATALF(
"Berkeley DB error: %s", e.what());
1350 catch(std::exception &e) {
1351 HT_FATALF(
"Berkeley DB error: %s", e.what());
1358 const String &aname, Dbt &key) {
1361 if (!
exists(txn, keystr, &isdir))
1370 key.set_data((
void *)keystr.c_str());
1371 key.set_size(keystr.length() + 1);
1376 std::vector<String> &anames)
1384 if (!
exists(txn, fname, &isdir))
1392 while ((ret = cursorp->get(&keym, &datam, DB_NEXT)) == 0) {
1397 if (currkey.size() < targetkey.size())
1400 size_t keysize = targetkey.size();
1401 if (!targetkey.compare(0, keysize, currkey, 0, keysize)) {
1404 String attribute(currkey.substr(keysize, currkey.size()));
1405 anames.push_back(attribute);
1408 }
catch(DbException &e) {
1409 HT_FATALF(
"Berkeley DB error: %s", e.what());
1411 }
catch(std::exception &e) {
1412 HT_FATALF(
"Berkeley DB error: %s", e.what());
1433 HT_DEBUG_OUT <<
"create_event txn="<< txn <<
" event type='"<< type <<
"' id="
1434 <<
id <<
" mask=" << mask <<
HT_END;
1442 sprintf(numbuf,
"%llu", (
Llu)
id);
1446 ret = cursorp->put(&keym, &datam, DB_KEYLAST);
1452 sprintf(numbuf,
"%lu", (
Lu)type);
1460 sprintf(numbuf,
"%lu", (
Lu)mask);
1466 catch (DbException &e) {
1467 if (e.get_errno() == DB_LOCK_DEADLOCK)
1469 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
1471 HT_ERRORF(
"Berkeley DB error: %s", e.what());
1481 uint32_t mask,
const String &name)
1498 catch (DbException &e) {
1499 if (e.get_errno() == DB_LOCK_DEADLOCK)
1501 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
1503 HT_ERRORF(
"Berkeley DB error: %s", e.what());
1512 uint32_t mask, uint32_t mode)
1524 sprintf(numbuf,
"%lu", (
Lu)mode);
1530 catch (DbException &e) {
1531 if (e.get_errno() == DB_LOCK_DEADLOCK)
1533 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
1535 HT_ERRORF(
"Berkeley DB error: %s", e.what());
1544 uint32_t mask, uint32_t mode,
1545 uint64_t generation)
1557 sprintf(numbuf,
"%llu", (
Llu)generation);
1563 catch (DbException &e) {
1564 if (e.get_errno() == DB_LOCK_DEADLOCK)
1566 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
1568 HT_ERRORF(
"Berkeley DB error: %s", e.what());
1578 const std::vector<uint64_t> &handles)
1584 uint32_t serialized_len = handles.size() * (
sizeof(uint64_t)) +
sizeof(uint32_t);
1587 HT_DEBUG_OUT <<
"set_event_notification_handles txn="<< txn <<
" event id="<<
id
1588 <<
" num notification handles=" << handles.size() <<
HT_END;
1592 for(uint32_t ii=0; ii< handles.size(); ++ii)
1595 Dbt data((
void *)buf.
base, serialized_len);
1608 catch (DbException &e) {
1609 if (e.get_errno() == DB_LOCK_DEADLOCK)
1611 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
1613 HT_ERRORF(
"Berkeley DB error: %s", e.what());
1639 sprintf(numbuf,
"%llu", (
Llu)
id);
1643 cursorp->get(&keym, &datam, DB_GET_BOTH);
1666 <<
"not found in DB" <<
HT_END;
1674 <<
" not found in DB" <<
HT_END;
1682 <<
" not found in DB" <<
HT_END;
1690 <<
" not found in DB" <<
HT_END;
1692 catch (DbException &e) {
1693 if (e.get_errno() == DB_LOCK_DEADLOCK)
1695 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
1697 HT_ERRORF(
"Berkeley DB error: %s", e.what());
1722 sprintf(numbuf,
"%llu", (
Llu)
id);
1725 if(cursorp->get(&keym, &datam, DB_GET_BOTH) == DB_NOTFOUND) {
1729 catch (DbException &e) {
1730 if (e.get_errno() == DB_LOCK_DEADLOCK)
1732 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
1734 HT_ERRORF(
"Berkeley DB error: %s", e.what());
1759 HT_DEBUG_OUT <<
"create_session txn="<< txn <<
" create session addr='"<< addr
1760 <<
" id="<<
id <<
HT_END;
1767 sprintf(numbuf,
"%llu", (
Llu)
id);
1771 ret = cursorp->put(&keym, &datam, DB_KEYLAST);
1790 catch (DbException &e) {
1791 if (e.get_errno() == DB_LOCK_DEADLOCK)
1793 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
1795 HT_ERRORF(
"Berkeley DB error: %s", e.what());
1800 <<
" create session addr='"<< addr <<
" id="<<
id <<
HT_END;
1829 keym.
set_str(session_handles_dir);
1832 ret = cursorp->get(&keym, &datam, DB_SET);
1833 while(ret != DB_NOTFOUND) {
1836 ret = cursorp->get(&keym, &datam, DB_NEXT_DUP);
1843 ret = cursorp->get(&keym, &datam, DB_SET);
1844 if (ret != DB_NOTFOUND) {
1845 ret = cursorp->del(0);
1858 sprintf(numbuf,
"%llu", (
Llu)
id);
1861 cursorp->get(&keym, &datam, DB_GET_BOTH);
1862 ret = cursorp->del(0);
1865 catch (DbException &e) {
1866 if (e.get_errno() == DB_LOCK_DEADLOCK)
1868 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
1870 HT_ERRORF(
"Berkeley DB error: %s", e.what());
1873 HT_DEBUG_OUT <<
"exitting delete_session txn=" << txn <<
" session id=" <<
id <<
HT_END;
1896 ret = cursorp->get(&keym, &datam, DB_SET);
1900 ret = cursorp->put(&keym, &datam, DB_CURRENT);
1903 catch (DbException &e) {
1904 if (e.get_errno() == DB_LOCK_DEADLOCK)
1906 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
1908 HT_ERRORF(
"Berkeley DB error: %s", e.what());
1912 HT_DEBUG_OUT <<
"exitting expire_session txn="<< txn <<
" session id=" <<
id <<
HT_END;
1929 HT_DEBUG_OUT <<
"add_session_handle txn="<< txn <<
" session id="<<
id
1930 <<
" handle id=" << handle_id <<
HT_END;
1935 keym.
set_str(session_handles_dir);
1936 sprintf(numbuf,
"%llu", (
Llu)handle_id);
1940 ret = cursorp->put(&keym, &datam, DB_KEYLAST);
1943 catch (DbException &e) {
1944 if (e.get_errno() == DB_LOCK_DEADLOCK)
1946 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
1948 HT_ERRORF(
"Berkeley DB error: %s", e.what());
1951 HT_DEBUG_OUT <<
"exitting add_session_handle txn="<< txn <<
" session id="<<
id
1952 <<
" handle id=" << handle_id <<
HT_END;
1973 keym.
set_str(session_handles_dir);
1976 ret = cursorp->get(&keym, &datam, DB_SET);
1977 while(ret != DB_NOTFOUND) {
1978 handles.push_back(strtoul((
const char *)datam.get_data(), 0, 0));
1979 ret = cursorp->get(&keym, &datam, DB_NEXT_DUP);
1982 catch (DbException &e) {
1983 if (e.get_errno() == DB_LOCK_DEADLOCK)
1985 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
1987 HT_ERRORF(
"Berkeley DB error: %s", e.what());
1991 HT_DEBUG_OUT <<
"exitting get_session_handles txn="<< txn <<
" session id="<<
id <<
HT_END;
2004 bool deleted =
false;
2008 HT_DEBUG_OUT <<
"delete_session_handle txn="<< txn <<
" session id="<<
id
2009 <<
" handle_id=" << handle_id <<
HT_END;
2015 keym.
set_str(session_handles_dir);
2016 sprintf(numbuf,
"%llu", (
Llu)handle_id);
2019 ret = cursorp->get(&keym, &datam, DB_GET_BOTH);
2023 if (ret != DB_NOTFOUND) {
2024 ret = cursorp->del(0);
2029 catch (DbException &e) {
2030 if (e.get_errno() == DB_LOCK_DEADLOCK)
2032 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
2034 HT_ERRORF(
"Berkeley DB error: %s", e.what());
2038 HT_DEBUG_OUT <<
"exitting delete_session_handle txn="<< txn <<
" session id="<<
id
2039 <<
" handle_id=" << handle_id <<
" deleted=" << deleted <<
HT_END;
2063 sprintf(numbuf,
"%llu", (
Llu)
id);
2066 if(cursorp->get(&keym, &datam, DB_GET_BOTH) == DB_NOTFOUND) {
2070 catch (DbException &e) {
2071 if (e.get_errno() == DB_LOCK_DEADLOCK)
2073 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
2075 HT_ERRORF(
"Berkeley DB error: %s", e.what());
2082 HT_DEBUG_OUT <<
"exitting session_exists txn="<< txn <<
" session id=" <<
id <<
HT_END;
2098 HT_DEBUG_OUT <<
"set_session_name txn="<< txn <<
" name='"<< name <<
"' id="<<
id <<
HT_END;
2105 ret = cursorp->get(&keym, &datam, DB_SET);
2107 if (ret == DB_NOTFOUND)
2110 ret = cursorp->put(&keym, &datam, DB_CURRENT);
2114 catch (DbException &e) {
2115 if (e.get_errno() == DB_LOCK_DEADLOCK)
2117 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
2119 HT_ERRORF(
"Berkeley DB error: %s", e.what());
2123 HT_DEBUG_OUT <<
"exitting set_session_name txn="<< txn <<
" name='"<< name <<
"'" <<
HT_END;
2147 ret = cursorp->get(&keym, &datam, DB_SET);
2149 HT_ASSERT(ret == 0 || ret == DB_NOTFOUND);
2151 if (ret == DB_NOTFOUND)
2156 catch (DbException &e) {
2157 if (e.get_errno() == DB_LOCK_DEADLOCK)
2159 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
2161 HT_ERRORF(
"Berkeley DB error: %s", e.what());
2166 <<
" session id=" <<
id <<
" name="<< name <<
HT_END;
2175 uint32_t open_flags, uint32_t event_mask, uint64_t session_id,
2176 bool locked, uint32_t del_state)
2186 HT_DEBUG_OUT <<
"create_handle txn="<< txn <<
" id="<<
id <<
" node='"<< node_name
2187 <<
"' open_flags=" << open_flags <<
" event_mask="<< event_mask
2188 <<
" session_id=" << session_id <<
" locked=" << locked
2189 <<
" del_state=" << del_state <<
HT_END;
2196 sprintf(numbuf,
"%llu", (
Llu)
id);
2200 ret = cursorp->put(&keym, &datam, DB_KEYLAST);
2214 sprintf(numbuf,
"%lu", (
Lu)open_flags);
2223 sprintf(numbuf,
"%lu", (
Lu)del_state);
2232 sprintf(numbuf,
"%lu", (
Lu)event_mask);
2241 sprintf(numbuf,
"%llu", (
Llu)session_id);
2259 catch (DbException &e) {
2260 if (e.get_errno() == DB_LOCK_DEADLOCK)
2262 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
2264 HT_ERRORF(
"Berkeley DB error: %s", e.what());
2268 HT_DEBUG_OUT <<
"exitting create_handle txn="<< txn <<
" id="<<
id <<
" node='"<< node_name
2269 <<
"' open_flags=" << open_flags <<
" event_mask="<< event_mask
2270 <<
" session_id=" << session_id <<
" locked=" << locked
2271 <<
" del_state=" << del_state <<
HT_END;
2336 sprintf(numbuf,
"%llu", (
Llu)
id);
2340 ret = cursorp->get(&keym, &datam, DB_GET_BOTH);
2342 ret = cursorp->del(0);
2346 catch (DbException &e) {
2347 if (e.get_errno() == DB_LOCK_DEADLOCK)
2349 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
2351 HT_ERRORF(
"Berkeley DB error: %s", e.what());
2354 HT_DEBUG_OUT <<
"exitting delete_handle txn="<< txn <<
" handle id="
2372 HT_DEBUG_OUT <<
"set_handle_del_state txn="<< txn <<
" handle id="
2373 <<
id <<
" del_state=" << del_state <<
HT_END;
2382 ret = cursorp->get(&keym, &datam, DB_SET);
2385 sprintf(numbuf,
"%lu", (
Lu)del_state);
2388 ret = cursorp->put(&keym, &datam, DB_CURRENT);
2391 catch (DbException &e) {
2392 HT_ERRORF(
"Berkeley DB error: %s", e.what());
2393 if (e.get_errno() == DB_LOCK_DEADLOCK)
2399 HT_DEBUG_OUT <<
"exitting set_handle_del_state txn="<< txn <<
" handle id="
2400 <<
id <<
" del_state=" << del_state <<
HT_END;
2417 HT_DEBUG_OUT <<
"set_handle_open_flags txn="<< txn <<
" handle id="
2418 <<
id <<
" open_flags=" << open_flags <<
HT_END;
2427 ret = cursorp->get(&keym, &datam, DB_SET);
2430 sprintf(numbuf,
"%lu", (
Lu)open_flags);
2433 ret = cursorp->put(&keym, &datam, DB_CURRENT);
2436 catch (DbException &e) {
2437 if (e.get_errno() == DB_LOCK_DEADLOCK)
2439 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
2441 HT_ERRORF(
"Berkeley DB error: %s", e.what());
2445 HT_DEBUG_OUT <<
"exitting set_handle_open_flags txn="<< txn <<
" handle id="
2446 <<
id <<
" open_flags=" << open_flags <<
HT_END;
2463 HT_DEBUG_OUT <<
"set_handle_event_mask txn="<< txn <<
" handle id="
2464 <<
id <<
" event_mask=" << event_mask <<
HT_END;
2473 ret = cursorp->get(&keym, &datam, DB_SET);
2476 sprintf(numbuf,
"%lu", (
Lu)event_mask);
2479 ret = cursorp->put(&keym, &datam, DB_CURRENT);
2482 catch (DbException &e) {
2483 if (e.get_errno() == DB_LOCK_DEADLOCK)
2485 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
2487 HT_ERRORF(
"Berkeley DB error: %s", e.what());
2491 HT_DEBUG_OUT <<
"exitting set_handle_event_mask txn="<< txn <<
" handle id="
2492 <<
id <<
" event_mask=" << event_mask <<
HT_END;
2507 uint32_t event_mask;
2518 ret = cursorp->get(&keym, &datam, DB_SET);
2520 event_mask = (uint32_t)strtoull(datam.
get_str(), 0, 0);
2522 catch (DbException &e) {
2523 if (e.get_errno() == DB_LOCK_DEADLOCK)
2525 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
2527 HT_ERRORF(
"Berkeley DB error: %s", e.what());
2531 HT_DEBUG_OUT <<
"exitting get_handle_event_mask txn="<< txn <<
" handle id=" <<
id
2532 <<
" event_mask=" << event_mask <<
HT_END;
2550 HT_DEBUG_OUT <<
"set_handle_locked txn="<< txn <<
" handle id=" <<
id
2551 <<
" locked=" << locked <<
HT_END;
2559 ret = cursorp->get(&keym, &datam, DB_SET);
2567 ret = cursorp->put(&keym, &datam, DB_CURRENT);
2570 catch (DbException &e) {
2571 if (e.get_errno() == DB_LOCK_DEADLOCK)
2573 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
2575 HT_ERRORF(
"Berkeley DB error: %s", e.what());
2578 HT_DEBUG_OUT <<
"exitting set_handle_locked txn="<< txn <<
" handle id=" <<
id
2579 <<
" locked=" << locked <<
HT_END;
2602 sprintf(numbuf,
"%llu", (
Llu)
id);
2605 if(cursorp->get(&keym, &datam, DB_GET_BOTH) == DB_NOTFOUND) {
2609 catch (DbException &e) {
2610 if (e.get_errno() == DB_LOCK_DEADLOCK)
2612 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
2614 HT_ERRORF(
"Berkeley DB error: %s", e.what());
2618 HT_DEBUG_OUT <<
"exitting handle_exists txn="<< txn <<
" handle id=" <<
id
2619 <<
" exists=" << exists <<
HT_END;
2651 else if (buf ==
"0")
2658 catch (DbException &e) {
2659 if (e.get_errno() == DB_LOCK_DEADLOCK)
2661 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
2663 HT_ERRORF(
"Berkeley DB error: %s", e.what());
2667 HT_DEBUG_OUT <<
"exitting set_handle_locked txn="<< txn <<
" handle id=" <<
id
2668 <<
" locked=" << locked <<
HT_END;
2696 catch (DbException &e) {
2697 if (e.get_errno() == DB_LOCK_DEADLOCK)
2699 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
2701 HT_ERRORF(
"Berkeley DB error: %s", e.what());
2705 HT_DEBUG_OUT <<
"exitting get_handle_node_name txn="<< txn <<
" handle id=" <<
id
2706 <<
" node_name=" << node_name <<
HT_END;
2732 del_state = (uint32_t)strtoul(datam.
get_str(), 0, 0);
2734 catch (DbException &e) {
2735 HT_ERRORF(
"Berkeley DB error: %s", e.what());
2736 if (e.get_errno() == DB_LOCK_DEADLOCK)
2742 HT_DEBUG_OUT <<
"exitting get_handle_del_state txn="<< txn <<
" handle id="
2743 <<
id <<
" del_state=" << del_state <<
HT_END;
2756 uint32_t open_flags;
2770 open_flags = (uint32_t)strtoul(datam.
get_str(), 0, 0);
2773 catch (DbException &e) {
2774 if (e.get_errno() == DB_LOCK_DEADLOCK)
2776 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
2778 HT_ERRORF(
"Berkeley DB error: %s", e.what());
2782 HT_DEBUG_OUT <<
"exitting get_handle_open_flags txn="<< txn <<
" handle id="
2783 <<
id <<
" open_flags=" << open_flags <<
HT_END;
2796 uint64_t session_id;
2811 session_id = (uint64_t)strtoull(datam.
get_str(), 0, 0);
2813 catch (DbException &e) {
2814 if (e.get_errno() == DB_LOCK_DEADLOCK)
2816 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
2818 HT_ERRORF(
"Berkeley DB error: %s", e.what());
2822 HT_DEBUG_OUT <<
"get_handle_session txn="<< txn <<
" id="<<
id <<
" session_id="
2834 bool ephemeral, uint64_t lock_generation, uint32_t cur_lock_mode,
2835 uint64_t exclusive_handle)
2845 HT_DEBUG_OUT <<
"create_node txn="<< txn <<
" create node ='"<< name
2846 <<
" ephemeral=" << ephemeral <<
" lock_mode=" << cur_lock_mode
2847 <<
" lock_generation=" << lock_generation <<
" exclusive_handle="
2848 <<
" exclusive_handle" <<
HT_END;
2858 ret = cursorp->put(&keym, &datam, DB_KEYLAST);
2876 sprintf(numbuf,
"%lu", (
Lu)cur_lock_mode);
2885 sprintf(numbuf,
"%llu", (
Llu)lock_generation);
2894 sprintf(numbuf,
"%llu", (
Llu)exclusive_handle);
2901 catch (DbException &e) {
2902 if (e.get_errno() == DB_LOCK_DEADLOCK)
2904 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
2906 HT_ERRORF(
"Berkeley DB error: %s", e.what());
2909 HT_DEBUG_OUT <<
"exitting create_node txn="<< txn <<
" create node ='"
2910 << name <<
"' ephemeral=" << ephemeral <<
" lock_mode="
2912 <<
" lock_generation=" << lock_generation <<
" exclusive_handle="
2913 <<
" exclusive_handle" <<
HT_END;
2922 uint64_t lock_generation)
2932 HT_DEBUG_OUT <<
"set_node_lock_generation txn="<< txn <<
" node=" << name
2933 <<
" lock_generation=" << lock_generation <<
HT_END;
2942 ret = cursorp->get(&keym, &datam, DB_SET);
2945 sprintf(numbuf,
"%llu", (
Llu)lock_generation);
2948 ret = cursorp->put(&keym, &datam, DB_CURRENT);
2951 catch (DbException &e) {
2952 if (e.get_errno() == DB_LOCK_DEADLOCK)
2954 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
2956 HT_ERRORF(
"Berkeley DB error: %s", e.what());
2960 HT_DEBUG_OUT <<
"exitting set_node_lock_generation txn="<< txn <<
" node=" << name
2961 <<
" lock_generation=" << lock_generation <<
HT_END;
2973 uint64_t lock_generation=0;
2989 ret = cursorp->get(&keym, &datam, DB_SET);
2992 lock_generation = (uint64_t)strtoull(datam.
get_str(), 0, 0);
2994 sprintf(numbuf,
"%llu", (
Llu)lock_generation);
2997 ret = cursorp->put(&keym, &datam, DB_CURRENT);
3000 catch (DbException &e) {
3001 if (e.get_errno() == DB_LOCK_DEADLOCK)
3003 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
3005 HT_ERRORF(
"Berkeley DB error: %s", e.what());
3009 HT_DEBUG_OUT <<
"exitting incr_node_lock_generation txn="<< txn <<
" node="<< name
3010 <<
" lock_generation=" << lock_generation <<
HT_END;
3012 return lock_generation;
3029 HT_DEBUG_OUT <<
"set_node_ephemeral txn="<< txn <<
" node_name=" << name
3030 <<
" ephemeral=" << ephemeral <<
HT_END;
3038 ret = cursorp->get(&keym, &datam, DB_SET);
3046 ret = cursorp->put(&keym, &datam, DB_CURRENT);
3049 catch (DbException &e) {
3050 if (e.get_errno() == DB_LOCK_DEADLOCK)
3052 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
3054 HT_ERRORF(
"Berkeley DB error: %s", e.what());
3058 HT_DEBUG_OUT <<
"exitting set_node_ephemeral txn="<< txn <<
" node_name=" << name
3059 <<
" ephemeral=" << ephemeral <<
HT_END;
3086 if (!strcmp(datam.
get_str(),
"0"))
3088 else if (!strcmp(datam.
get_str(),
"1"))
3093 catch (DbException &e) {
3094 if (e.get_errno() == DB_LOCK_DEADLOCK)
3096 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
3098 HT_ERRORF(
"Berkeley DB error: %s", e.what());
3102 HT_DEBUG_OUT <<
"exitting node_is_ephemeral txn=" << txn <<
" node_name= " << name
3103 <<
" ephemeral=" << ephemeral <<
HT_END;
3121 HT_DEBUG_OUT <<
"set_node_cur_lock_mode txn="<< txn <<
" node=" << name
3122 <<
" lock_mode=" << lock_mode <<
HT_END;
3131 ret = cursorp->get(&keym, &datam, DB_SET);
3134 sprintf(numbuf,
"%lu", (
Lu)lock_mode);
3137 ret = cursorp->put(&keym, &datam, DB_CURRENT);
3140 catch (DbException &e) {
3141 if (e.get_errno() == DB_LOCK_DEADLOCK)
3143 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
3145 HT_ERRORF(
"Berkeley DB error: %s", e.what());
3149 HT_DEBUG_OUT <<
"exitting set_node_cur_lock_mode txn="<< txn <<
" node=" << name
3150 <<
" lock_mode=" << lock_mode <<
HT_END;
3176 ret = cursorp->get(&keym, &datam, DB_SET);
3178 lock_mode = (uint32_t) strtoull(datam.
get_str(), 0, 0);
3180 catch (DbException &e) {
3181 if (e.get_errno() == DB_LOCK_DEADLOCK)
3183 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
3185 HT_ERRORF(
"Berkeley DB error: %s", e.what());
3189 HT_DEBUG_OUT <<
"exitting get_node_cur_lock_mode txn="<< txn <<
" node=" << name
3190 <<
" lock_mode=" << lock_mode <<
HT_END;
3199 const String &name, uint64_t exclusive_lock_handle)
3208 HT_DEBUG_OUT <<
"set_node_exclusive_lock_handle txn="<< txn <<
" node=" << name
3209 <<
" exclusive_lock_handle=" << exclusive_lock_handle <<
HT_END;
3218 ret = cursorp->get(&keym, &datam, DB_SET);
3221 sprintf(numbuf,
"%llu", (
Llu)exclusive_lock_handle);
3224 ret = cursorp->put(&keym, &datam, DB_CURRENT);
3227 catch (DbException &e) {
3228 if (e.get_errno() == DB_LOCK_DEADLOCK)
3230 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
3232 HT_ERRORF(
"Berkeley DB error: %s", e.what());
3235 HT_DEBUG_OUT <<
"exitting set_node_exclusive_lock_handle txn="<< txn <<
" node="<< name
3236 <<
" exclusive_lock_handle=" << exclusive_lock_handle <<
HT_END;
3250 uint64_t exclusive_lock_handle=0;
3252 HT_DEBUG_OUT <<
"get_node_exclusive_lock_handle txn="<< txn <<
" node=" << name <<
HT_END;
3262 ret = cursorp->get(&keym, &datam, DB_SET);
3264 exclusive_lock_handle = (uint64_t)strtoull(datam.
get_str(), 0, 0);
3266 catch (DbException &e) {
3267 if (e.get_errno() == DB_LOCK_DEADLOCK)
3269 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
3271 HT_ERRORF(
"Berkeley DB error: %s", e.what());
3275 HT_DEBUG_OUT <<
"exitting get_node_exclusive_lock_handle txn=" << txn <<
" node=" << name
3276 <<
" exclusive_lock_handle=" << exclusive_lock_handle <<
HT_END;
3278 return exclusive_lock_handle;
3295 HT_DEBUG_OUT <<
"add_node_handle txn="<< txn <<
" node="<< name <<
" handle id=" << handle_id
3302 keym.
set_str(node_handles_dir);
3303 sprintf(numbuf,
"%llu", (
Llu)handle_id);
3307 ret = cursorp->put(&keym, &datam, DB_KEYLAST);
3310 catch (DbException &e) {
3311 if (e.get_errno() == DB_LOCK_DEADLOCK)
3313 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
3315 HT_ERRORF(
"Berkeley DB error: %s", e.what());
3318 HT_DEBUG_OUT <<
"exitting add_node_handle txn="<< txn <<
" node="<< name
3319 <<
" handle id=" << handle_id <<
HT_END;
3332 uint64_t handle, session;
3336 bool has_notifications =
false;
3338 HT_DEBUG_OUT <<
"get_node_event_notification_map txn="<< txn <<
" node="<< name <<
HT_END;
3344 keym.
set_str(node_handles_dir);
3346 ret = cursorp->get(&keym, &datam, DB_SET);
3349 while (ret != DB_NOTFOUND) {
3351 handle = (uint64_t)strtoull(datam.
get_str(), 0, 0);
3354 if ((mask&event_mask) != 0) {
3356 handles_to_sessions[handle] = session;
3357 has_notifications =
true;
3359 ret = cursorp->get(&keym, &datam, DB_NEXT_DUP);
3362 catch (DbException &e) {
3363 if (e.get_errno() == DB_LOCK_DEADLOCK)
3365 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
3367 HT_ERRORF(
"Berkeley DB error: %s", e.what());
3371 HT_DEBUG_OUT <<
"exitting get_node_event_notification_map txn=" << txn <<
" node="<< name
3372 <<
" has_notifications=" << has_notifications <<
HT_END;
3373 return has_notifications;
3390 HT_DEBUG_OUT <<
"delete_node_handle txn="<< txn <<
" node="<< name
3391 <<
" handle_id=" << handle_id <<
HT_END;
3397 keym.
set_str(node_handles_dir);
3398 sprintf(numbuf,
"%llu", (
Llu)handle_id);
3401 ret = cursorp->get(&keym, &datam, DB_GET_BOTH);
3404 ret = cursorp->del(0);
3407 catch (DbException &e) {
3408 if (e.get_errno() == DB_LOCK_DEADLOCK)
3410 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
3412 HT_ERRORF(
"Berkeley DB error: %s", e.what());
3415 HT_DEBUG_OUT <<
"exitting delete_node_handle txn="<< txn <<
" node="<< name
3416 <<
" handle_id=" << handle_id <<
HT_END;
3435 HT_DEBUG_OUT <<
"add_node_pending_lock_request txn="<< txn <<
" node=" << name
3441 keym.
set_str(node_pending_locks_dir);
3442 sprintf(numbuf,
"%llu", (
Llu)request.
handle);
3446 ret = cursorp->put(&keym, &datam, DB_KEYLAST);
3451 sprintf(numbuf,
"%lu", (
Lu)request.
mode);
3456 catch (DbException &e) {
3457 if (e.get_errno() == DB_LOCK_DEADLOCK)
3459 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
3461 HT_ERRORF(
"Berkeley DB error: %s", e.what());
3465 HT_DEBUG_OUT <<
" exitting add_node_pending_lock_request txn="<< txn <<
" node=" << name
3479 bool has_pending_lock_request =
false;
3484 HT_DEBUG_OUT <<
"node_has_pending_lock_request txn=" << txn <<
" node=" << name <<
HT_END;
3491 keym.
set_str(node_pending_locks_dir);
3493 ret = cursorp->get(&keym, &datam, DB_SET);
3495 HT_ASSERT(ret == 0 || ret == DB_NOTFOUND);
3499 handle_id = (uint64_t) strtoull(datam.
get_str(), 0, 0);
3504 has_pending_lock_request =
true;
3507 catch (DbException &e) {
3508 if (e.get_errno() == DB_LOCK_DEADLOCK)
3510 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
3512 HT_ERRORF(
"Berkeley DB error: %s", e.what());
3516 HT_DEBUG_OUT <<
" exitting node_has_pending_lock_request txn="<< txn <<
" node=" << name
3517 <<
" node_has_pending_lock_request=" << has_pending_lock_request <<
HT_END;
3519 return has_pending_lock_request;
3533 bool has_pending_lock_request =
false;
3538 HT_DEBUG_OUT <<
"get_node_pending_lock_request txn=" << txn <<
" node=" << name <<
HT_END;
3545 keym.
set_str(node_pending_locks_dir);
3547 ret = cursorp->get(&keym, &datam, DB_SET);
3548 HT_ASSERT(ret == 0 || ret == DB_NOTFOUND);
3552 has_pending_lock_request =
true;
3553 handle_id = (uint64_t) strtoull(datam.
get_str(), 0, 0);
3559 front_req.
handle = handle_id;
3560 front_req.
mode = (uint32_t) strtoull(datam.
get_str(), 0, 0);
3563 catch (DbException &e) {
3564 if (e.get_errno() == DB_LOCK_DEADLOCK)
3566 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
3568 HT_ERRORF(
"Berkeley DB error: %s", e.what());
3572 HT_DEBUG_OUT <<
" exitting get_node_pending_lock_request txn="<< txn <<
" node=" << name
3573 <<
" has_pending_lock_request=" << has_pending_lock_request <<
HT_END;
3575 return has_pending_lock_request;
3582 const String &name, uint64_t handle_id)
3591 HT_DEBUG_OUT <<
"remove_node_pending_lock_request txn="<< txn <<
" node=" << name
3592 <<
" handle id=" << handle_id <<
HT_END;
3599 keym.
set_str(node_pending_locks_dir);
3600 sprintf(numbuf,
"%llu", (
Llu)handle_id);
3603 ret = cursorp->get(&keym, &datam, DB_GET_BOTH);
3606 ret = cursorp->del(0);
3614 catch (DbException &e) {
3615 if (e.get_errno() == DB_LOCK_DEADLOCK)
3617 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
3619 HT_ERRORF(
"Berkeley DB error: %s", e.what());
3623 HT_DEBUG_OUT <<
"exitting remove_node_pending_lock_request txn="<< txn
3624 <<
" node=" << name <<
" handle id=" << handle_id <<
HT_END;
3641 HT_DEBUG_OUT <<
"add_node_shared_lock_handle txn="<< txn <<
" node="<< name
3642 <<
" handle id=" << handle_id <<
HT_END;
3648 keym.
set_str(node_shared_handles_dir);
3649 sprintf(numbuf,
"%llu", (
Llu)handle_id);
3653 ret = cursorp->put(&keym, &datam, DB_KEYLAST);
3656 catch (DbException &e) {
3657 if (e.get_errno() == DB_LOCK_DEADLOCK)
3659 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
3661 HT_ERRORF(
"Berkeley DB error: %s", e.what());
3664 HT_DEBUG_OUT <<
"exitting add_node_shared_lock_handle txn="<< txn <<
" node="<< name
3665 <<
" handle id=" << handle_id <<
HT_END;
3679 bool has_shared_lock_handles=
false;
3681 HT_DEBUG_OUT <<
"node_has_shared_lock_handles txn="<< txn <<
" node="<< name <<
HT_END;
3687 keym.
set_str(node_shared_handles_dir);
3689 ret = cursorp->get(&keym, &datam, DB_SET);
3690 HT_ASSERT(ret == 0 || ret == DB_NOTFOUND);
3692 if (ret != DB_NOTFOUND)
3693 has_shared_lock_handles =
true;
3695 catch (DbException &e) {
3696 if (e.get_errno() == DB_LOCK_DEADLOCK)
3698 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
3700 HT_ERRORF(
"Berkeley DB error: %s", e.what());
3704 HT_DEBUG_OUT <<
"exitting node_has_shared_lock_handle txn="<< txn <<
" node="<< name
3705 <<
" has_shared_lock_handles=" << has_shared_lock_handles <<
HT_END;
3706 return has_shared_lock_handles;
3723 HT_DEBUG_OUT <<
"remove_node_shared_lock_handle txn="<< txn <<
" node="<< name
3724 <<
" handle_id=" << handle_id <<
HT_END;
3730 keym.
set_str(node_shared_handles_dir);
3731 sprintf(numbuf,
"%llu", (
Llu)handle_id);
3734 ret = cursorp->get(&keym, &datam, DB_GET_BOTH);
3737 ret = cursorp->del(0);
3740 catch (DbException &e) {
3741 if (e.get_errno() == DB_LOCK_DEADLOCK)
3743 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
3745 HT_ERRORF(
"Berkeley DB error: %s", e.what());
3748 HT_DEBUG_OUT <<
"exitting remove_node_shared_lock_handle txn="<< txn <<
" node="<< name
3749 <<
" handle_id=" << handle_id <<
HT_END;
3774 ret = cursorp->get(&keym, &datam, DB_GET_BOTH);
3776 ret = cursorp->del(0);
3807 catch (DbException &e) {
3808 if (e.get_errno() == DB_LOCK_DEADLOCK)
3810 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
3812 HT_ERRORF(
"Berkeley DB error: %s", e.what());
3815 HT_DEBUG_OUT <<
"exitting delete_node txn="<< txn <<
" node="
3832 HT_DEBUG_OUT <<
"node_exists txn="<< txn <<
" node name="
3843 if(cursorp->get(&keym, &datam, DB_GET_BOTH) == DB_NOTFOUND) {
3847 catch (DbException &e) {
3848 if (e.get_errno() == DB_LOCK_DEADLOCK)
3850 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
3852 HT_ERRORF(
"Berkeley DB error: %s", e.what());
3856 HT_DEBUG_OUT <<
"exitting node_exists txn="<< txn <<
" node name =" << name
3857 <<
" exists=" << exists <<
HT_END;
3866 std::vector<uint64_t> &handles)
3881 keym.
set_str(node_handles_dir);
3883 ret = cursorp->get(&keym, &datam, DB_SET);
3885 while (ret != DB_NOTFOUND) {
3887 handles.push_back((uint64_t)strtoull(datam.
get_str(), 0, 0));
3888 ret = cursorp->get(&keym, &datam, DB_NEXT_DUP);
3891 catch (DbException &e) {
3892 if (e.get_errno() == DB_LOCK_DEADLOCK)
3894 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
3896 HT_ERRORF(
"Berkeley DB error: %s", e.what());
3914 bool has_open_handles =
false;
3915 uint64_t open_handle;
3924 keym.
set_str(node_handles_dir);
3926 ret = cursorp->get(&keym, &datam, DB_SET);
3928 HT_ASSERT(ret == 0 || ret == DB_NOTFOUND);
3930 open_handle = (uint64_t) strtoull((
const char *)datam.get_data(), 0, 0);
3931 HT_DEBUG_OUT <<
"node_has_open_handles txn=" << txn <<
" node=" << name
3932 <<
" at least one open_handle=" << open_handle <<
HT_END;
3933 has_open_handles =
true;
3936 catch (DbException &e) {
3937 if (e.get_errno() == DB_LOCK_DEADLOCK)
3939 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
3941 HT_ERRORF(
"Berkeley DB error: %s", e.what());
3945 HT_DEBUG_OUT <<
"node_has_open_handles txn=" << txn <<
" node=" << name
3946 <<
" has_open_handles=" << has_open_handles <<
HT_END;
3947 return has_open_handles;
3963 HT_DEBUG_OUT <<
"get_next_id_i64 txn="<< txn <<
" id_type=" << id_type <<
" increment="
3983 ret = cursorp->get(&keym, &datam, DB_SET);
3987 retval = strtoull((
const char *)datam.get_data(), 0, 0);
3989 sprintf(numbuf,
"%llu", (
Llu)retval+1);
3991 ret = cursorp->put(&keym, &datam, DB_CURRENT);
3995 catch (DbException &e) {
3996 if (e.get_errno() == DB_LOCK_DEADLOCK)
3998 else if (e.get_errno() == DB_REP_HANDLE_DEAD)
4000 HT_ERRORF(
"Berkeley DB error: %s", e.what());
4004 HT_DEBUG_OUT <<
"get_next_id_i64 txn="<< txn <<
" id_type=" << id_type <<
" increment="
4005 << increment <<
" retval=" << retval <<
HT_END;
4012 <<
", m_db_txn=" << txn.
db_txn <<
"}";
uint32_t get_handle_del_state(BDbTxn &txn, uint64_t id)
Retrieves system information (hardware, installation directory, etc)
uint64_t handle
Node handle ID.
void set_session_name(BDbTxn &txn, uint64_t id, const String &name)
const String NEXT_SESSION_ID
void set_handle_open_flags(BDbTxn &txn, uint64_t id, uint32_t open_flags)
void add_node_pending_lock_request(BDbTxn &txn, const String &name, LockRequest &request)
Adds a lock request.
BDbHandlesPtr get_db_handles()
const String NEXT_EVENT_ID
bool node_has_shared_lock_handles(BDbTxn &txn, const String &name)
std::chrono::steady_clock::duration m_log_gc_interval
static void db_msg_callback(const DbEnv *dbenv, const char *msg)
String get_event_key(uint64_t id, uint32_t type)
std::string String
A String is simply a typedef to std::string.
Compatibility class for boost::filesystem::path.
static void db_err_callback(const DbEnv *dbenv, const char *errpfx, const char *msg)
void set_str(const std::string &str)
void delete_node_shared_lock_handle(BDbTxn &txn, const String &name, uint64_t handle_id)
bool get_xattr_i32(BDbTxn &txn, const String &fname, const String &aname, uint32_t *valuep)
static Endpoint parse_endpoint(const char *endpoint, int defport=0)
Parse an endpoint string in (host:port) format.
void finish_election()
Finish master election.
Db * handle_namespace_db
Filesystem namespace database handle.
void get_handle_node(BDbTxn &txn, uint64_t id, String &node_name)
void add_node_handle(BDbTxn &txn, const String &name, uint64_t handle)
Manages transaction state.
bool incr_attr(BDbTxn &txn, const String &fname, const String &aname, uint64_t *valuep)
String get_session_key(uint64_t id, uint32_t type)
void create_handle(BDbTxn &txn, uint64_t id, String node_name, uint32_t open_flags, uint32_t event_mask, uint64_t session_id, bool locked, uint32_t del_state)
void create_node(BDbTxn &txn, const String &name, bool ephemeral=false, uint64_t lock_generation=0, uint32_t cur_lock_mode=0, uint64_t exclusive_handle=0)
long long unsigned int Llu
Shortcut for printf formats.
Po::typed_value< String > * str(String *v=0)
void create(BDbTxn &txn, const String &fname, bool temp)
const String SESSIONS_STR
std::shared_ptr< BDbHandles > BDbHandlesPtr
Smart pointer to BDbHandles.
static bool exists(const String &fname)
Checks if a file or directory exists.
Declarations for BerkeleyDbFilesystem.
void delete_session(BDbTxn &txn, uint64_t id)
bool node_is_ephemeral(BDbTxn &txn, const String &name)
void set_node_cur_lock_mode(BDbTxn &txn, const String &name, uint32_t lock_mode)
#define HT_ON_SCOPE_EXIT(...)
ThreadHandleMap m_thread_handle_map
bool node_has_pending_lock_request(BDbTxn &txn, const String &name)
Encapsulates replication state.
uint8_t * ptr
Pointer to the end of the used part of the buffer.
void add_node_shared_lock_handle(BDbTxn &txn, const String &name, uint64_t handle)
A dynamic, resizable and reference counted memory buffer.
void set_handle_event_mask(BDbTxn &txn, uint64_t id, uint32_t event_mask)
void get_session_handles(BDbTxn &txn, uint64_t id, std::vector< uint64_t > &handles)
static const char NODE_ATTR_DELIM
#define HT_EXPECT(_e_, _code_)
uint32_t m_max_unused_logs
bool election_finished()
Check if master election is finished.
bool exists(BDbTxn &txn, String fname, bool *is_dir_p=0)
Compatibility class for boost::filesystem::path.
void get_all_names(BDbTxn &txn, std::vector< String > &names)
std::unordered_map< uint64_t, uint64_t > NotificationMap
Hash map from Node handle ID to Session ID.
bool node_has_open_handles(BDbTxn &txn, const String &name)
void set_node_ephemeral(BDbTxn &txn, const String &name, bool ephemeral)
bool has_attr
Boolean value indicating whether or not this entry is a directory.
bool status(ContextPtr &context, Timer &timer, Status &status)
Runs a status check on the master.
void do_checkpoint()
Checkpoints the BerkeleyDB database.
#define HT_DEBUG_ATTR_(_txn_, _fn_, _an_, _k_, _v_, _l_)
bool handle_is_locked(BDbTxn &txn, uint64_t id)
bool delete_session_handle(BDbTxn &txn, uint64_t id, uint64_t handle_id)
static bool is_ipv4(const char *ip)
Tests whether the input string in n.n.n.n format (base 10)
bool delete_node(BDbTxn &txn, const String &name)
std::shared_ptr< Properties > PropertiesPtr
bool get_node_event_notification_map(BDbTxn &txn, const String &name, uint32_t event_mask, NotificationMap &handles_to_sessions)
Logging routines and macros.
bool get_node_pending_lock_request(BDbTxn &txn, const String &name, LockRequest &front_req)
Check if a node has any pending lock requests from non-expired handles.
static void db_event_callback(DbEnv *dbenv, uint32_t which, void *info)
void encode_i32(uint8_t **bufp, uint32_t val)
Encode a 32-bit integer in little-endian order.
uint64_t get_node_exclusive_lock_handle(BDbTxn &txn, const String &name)
void start_transaction(BDbTxn &txn)
Creates a new BerkeleyDB transaction.
void set_handle_locked(BDbTxn &txn, uint64_t id, bool locked)
Compatibility Macros for C/C++.
bool get_xattr(BDbTxn &txn, const String &fname, const String &aname, Hypertable::DynamicBuffer &vbuf)
void delete_node_handle(BDbTxn &txn, const String &name, uint64_t handle)
void set_handle_del_state(BDbTxn &txn, uint64_t id, uint32_t del_state)
void encode_i64(uint8_t **bufp, uint64_t val)
Encode a 64-bit integer in little-endian order.
uint32_t get_handle_event_mask(BDbTxn &txn, uint64_t id)
Functions to serialize/deserialize primitives to/from a memory buffer.
Db * handle_state_db
Transient state database handle.
std::unordered_map< int, String > replica_map
void free()
Clears the data; if this object is owner of the data then the allocated buffer is delete[]d...
Time related declarations.
void init_db_handles(const std::vector< Thread::id > &thread_ids)
DbTxn * db_txn
BerkeleyDB transaction object.
bool exists_xattr(BDbTxn &txn, const String &fname, const String &aname)
void create_event(BDbTxn &txn, uint32_t type, uint64_t id, uint32_t mask)
void mkdir(BDbTxn &txn, const String &name)
void add_session_handle(BDbTxn &txn, uint64_t id, uint64_t handle_id)
uint32_t get_node_cur_lock_mode(BDbTxn &txn, const String &name)
bool is_master()
Check if we're the current master.
const String NEXT_HANDLE_ID
#define HT_FATALF(msg,...)
bool event_exists(BDbTxn &txn, uint64_t id)
void set_xattr(BDbTxn &txn, const String &fname, const String &aname, const void *value, size_t value_len)
std::ostream & operator<<(std::ostream &out, const BDbTxn &txn)
Writes human-readable version of txn to an ostream.
void expire_session(BDbTxn &txn, uint64_t id)
bool handle_exists(BDbTxn &txn, uint64_t id)
void delete_node_pending_lock_request(BDbTxn &txn, const String &name, uint64_t handle)
void delete_event(BDbTxn &txn, uint64_t id)
uint32_t m_checkpoint_size_kb
Checkpoint size threshold in kilobytes.
#define HT_INFOF(msg,...)
void set_node_lock_generation(BDbTxn &txn, const String &name, uint64_t lock_generation)
#define HT_THROWF(_code_, _fmt_,...)
~BerkeleyDbFilesystem()
Destructor.
uint8_t * base
Pointer to the allocated memory buffer.
uint64_t get_handle_session(BDbTxn &txn, uint64_t id)
void set_xattr_i32(BDbTxn &txn, const String &fname, const String &aname, uint32_t value)
bool is_dir
Boolean value indicating whether or not this entry is a directory.
uint64_t get_next_id_i64(BDbTxn &txn, IdentifierType id_type, bool increment=false)
Encapsulates a lock request for a file node.
#define HT_DEBUG_ATTR(_txn_, _fn_, _an_, _k_, _v_)
bool list_xattr(BDbTxn &txn, const String &fname, std::vector< String > &anames)
bool session_exists(BDbTxn &txn, uint64_t id)
A String class based on std::string.
long unsigned int Lu
Shortcut for printf formats.
void set_event_notification_handles(BDbTxn &txn, uint64_t id, const std::vector< uint64_t > &handles)
#define HT_ERRORF(msg,...)
void create_session(BDbTxn &txn, uint64_t id, const String &addr)
String get_session_name(BDbTxn &txn, uint64_t id)
bool get_xattr_i64(BDbTxn &txn, const String &fname, const String &aname, uint64_t *valuep)
void close_db_cursor(Dbc **cursor)
String get_handle_key(uint64_t id, uint32_t type)
void unlink(BDbTxn &txn, const String &name)
static const char * ms_name_state_db
std::chrono::steady_clock::time_point m_last_log_gc_time
void delete_handle(BDbTxn &txn, uint64_t id)
void del_xattr(BDbTxn &txn, const String &fname, const String &aname)
ReplicationInfo m_replication_info
bool node_exists(BDbTxn &txn, const String &name)
System information and statistics based on libsigar.
String get_node_pending_lock_request_key(const String &name, uint64_t handle_id)
#define HT_THROW(_code_, _msg_)
std::string name
Directory entry name.
static const NetInfo & net_info()
Retrieves updated Network information (see SystemInfo.h)
void get_directory_listing(BDbTxn &txn, String fname, std::vector< DirEntry > &listing)
uint32_t get_handle_open_flags(BDbTxn &txn, uint64_t id)
uint8_t * add_unchecked(const void *data, size_t len)
Adds additional data without boundary checks.
IdentifierType
Enumeration for object identifier types.
void get_node_handles(BDbTxn &txn, const String &name, std::vector< uint64_t > &handles)
void wait_for_election()
Waits for master election to finish.
uint64_t incr_node_lock_generation(BDbTxn &txn, const String &name)
void get_directory_attr_listing(BDbTxn &txn, String fname, const String &aname, bool include_sub_entries, std::vector< DirEntryAttr > &listing)
String get_node_key(const String &name, uint32_t type)
void set_xattr_i64(BDbTxn &txn, const String &fname, const String &aname, uint64_t value)
void build_attr_key(BDbTxn &, String &keystr, const String &aname, Dbt &key)
void reserve(size_t len, bool nocopy=false)
Reserve space for additional data Will grow the space to exactly what's needed.
Executes user-defined functions when leaving the current scope.
High-level entry point to a service; wraps a host:port pair.
static const char * ms_name_namespace_db
void set_node_exclusive_lock_handle(BDbTxn &txn, const String &name, uint64_t exclusive_lock_handle)