MCPcopy Create free account
hub / github.com/Tencent/phxqueue / LockRun

Function LockRun

phxqueue/test/test_lock_main.cpp:83–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83void LockRun(const int vpid) {
84 comm::RetCode ret;
85
86 auto proc_name(string("test_lock.") + to_string(vpid));
87
88 comm::LogFunc log_func;
89 plugin::LoggerGoogle::GetLogger(proc_name, "/tmp/phxqueue/log", 3, log_func);
90 comm::Logger::GetInstance()->SetLogFunc(log_func);
91
92 config::LockConfig lock_config;
93 lock_config.Load();
94
95 vector<shared_ptr<const config::proto::Lock>> locks;
96 if (comm::RetCode::RET_OK != (ret = lock_config.GetAllLock(locks))) {
97 NLErr("GetAllLock ret %d", as_integer(ret));
98
99 return;
100 }
101 if (0 == locks.size()) {
102 NLErr("nr_lock 0");
103
104 return;
105 }
106 if (3 != locks.at(0)->addrs_size()) {
107 NLErr("locks[0]->nr_addr %zu != 3", locks[0]->addrs_size());
108
109 return;
110 }
111
112 auto path_base(string("/tmp/phxqueue/lock.") + to_string(vpid));
113
114 lock::LockOption opt;
115 opt.topic = "test";
116 opt.data_dir_path = path_base;
117 opt.ip = locks.at(0)->addrs(vpid).ip();
118 opt.port = locks.at(0)->addrs(vpid).port();
119 opt.paxos_port = locks.at(0)->addrs(vpid).paxos_port();
120 opt.log_func = log_func;
121 opt.nr_group = 2;
122
123 NLVerb("lock %d opt done", vpid);
124
125 lock::Lock lock(opt);
126 if (comm::RetCode::RET_OK != (ret = lock.Init())) {
127 NLErr("lock %d Init ret %d", vpid, as_integer(ret));
128
129 return;
130 }
131
132 NLVerb("lock %d Init ret %d", vpid, as_integer(ret));
133
134 sleep(10);
135
136 while (true) {
137 const int topic_id{1};
138 const int lock_id{1};
139 const string lock_key{string("test_lock_") + to_string(vpid)};
140 uint64_t version{0};

Callers 1

mainFunction · 0.85

Calls 7

as_integerFunction · 0.85
TestGetLockInfoFunction · 0.85
TestAcquireLockFunction · 0.85
SetLogFuncMethod · 0.80
LoadMethod · 0.80
GetAllLockMethod · 0.80
InitMethod · 0.45

Tested by

no test coverage detected