MCPcopy Create free account
hub / github.com/apache/incubator-pegasus / after_create_locknode

Method after_create_locknode

src/zookeeper/lock_struct.cpp:546–588  ·  view source on GitHub ↗

static*/

Source from the content-addressed store, hash-verified

544}
545/*static*/
546void lock_struct::after_create_locknode(lock_struct_ptr _this,
547 int ec,
548 std::shared_ptr<std::string> path)
549{
550 // as we create an ephe|seq node, so ZNODEEXISTS is not allowed
551 static const int allow_ec[] = {
552 ZOK, // succeed
553 ZINVALIDSTATE // operation timeout
554 };
555 static const int allow_state[] = {
556 lock_state::pending, lock_state::cancelled, lock_state::expired};
557
558 _this->_checker.only_one_thread_access();
559 __check_code(ec, allow_ec, 2, zerror(ec));
560 __check_code(_this->_state, allow_state, 3, string_state(_this->_state));
561
562 LOG_DEBUG("after create seq and ephe node, error({}), path({})", zerror(ec), *path);
563 if (_this->_state == lock_state::cancelled || _this->_state == lock_state::expired) {
564 LOG_INFO("current state({}), ignore event create lockdir({})",
565 string_state(_this->_state),
566 _this->_lock_dir);
567 if (ZOK == ec && _this->_state == lock_state::cancelled) {
568 _this->remove_my_locknode(std::move(*path), IGNORE_CALLBACK, REMOVE_FOR_CANCEL);
569 }
570 return;
571 }
572 if (ZINVALIDSTATE == ec) {
573 LOG_ERROR("create seq/ephe node ({}) in dir({}) got session expired",
574 distributed_lock_service_zookeeper::LOCK_NODE_PREFIX,
575 _this->_lock_dir);
576 _this->on_expire();
577 return;
578 }
579
580 char splitter[] = {'/', 0};
581 _this->_myself._node_seq_name = utils::get_last_component(*path, splitter);
582 _this->_myself._sequence_id = parse_seq_path(_this->_myself._node_seq_name);
583 CHECK_NE_MSG(_this->_myself._sequence_id, -1, "invalid seq path created");
584 LOG_INFO("create seq/ephe node in dir({}) ok, my_sequence_id({})",
585 _this->_lock_dir,
586 _this->_myself._sequence_id);
587 _this->get_lockdir_nodes();
588}
589
590void lock_struct::create_locknode()
591{

Callers

nothing calls this directly

Calls 6

string_stateFunction · 0.85
get_last_componentFunction · 0.85
remove_my_locknodeMethod · 0.80
on_expireMethod · 0.80
get_lockdir_nodesMethod · 0.80

Tested by

no test coverage detected