| 94 | } |
| 95 | |
| 96 | void SchedulerRun(const int vpid) { |
| 97 | comm::RetCode ret; |
| 98 | |
| 99 | auto proc_name(string("test_scheduler.") + to_string(vpid)); |
| 100 | |
| 101 | comm::LogFunc log_func; |
| 102 | plugin::LoggerGoogle::GetLogger(proc_name, "/tmp/phxqueue/log", 3, log_func); |
| 103 | comm::Logger::GetInstance()->SetLogFunc(log_func); |
| 104 | |
| 105 | config::SchedulerConfig scheduler_config; |
| 106 | scheduler_config.Load(); |
| 107 | |
| 108 | shared_ptr<const config::proto::Scheduler> template_scheduler; |
| 109 | if (comm::RetCode::RET_OK != (ret = scheduler_config.GetScheduler(template_scheduler))) { |
| 110 | NLErr("GetAllScheduler ret %d", as_integer(ret)); |
| 111 | |
| 112 | return; |
| 113 | } |
| 114 | if (3 != template_scheduler->addrs_size()) { |
| 115 | NLErr("scheduler->nr_addr %zu != 3", template_scheduler->addrs_size()); |
| 116 | |
| 117 | return; |
| 118 | } |
| 119 | |
| 120 | auto path_base(string("/tmp/phxqueue/scheduler.") + to_string(vpid)); |
| 121 | |
| 122 | scheduler::SchedulerOption opt; |
| 123 | opt.ip = template_scheduler->addrs(vpid).ip(); |
| 124 | opt.port = template_scheduler->addrs(vpid).port(); |
| 125 | opt.log_func = log_func; |
| 126 | |
| 127 | NLVerb("scheduler %d opt done", vpid); |
| 128 | |
| 129 | test::SimpleScheduler simple_scheduler(opt); |
| 130 | if (comm::RetCode::RET_OK != (ret = simple_scheduler.Init())) { |
| 131 | NLErr("scheduler %d Init ret %d", vpid, as_integer(ret)); |
| 132 | |
| 133 | return; |
| 134 | } |
| 135 | |
| 136 | NLVerb("scheduler %d Init ret %d", vpid, as_integer(ret)); |
| 137 | |
| 138 | sleep(10); |
| 139 | |
| 140 | if (vpid == 0) { |
| 141 | while (true) { |
| 142 | TestGetAddrScale(simple_scheduler); |
| 143 | sleep(2); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | sleep(1000); |
| 148 | } |
| 149 | |
| 150 | int main(int argc, char **argv) { |
| 151 | if (SIG_ERR == signal(SIGCHLD, SIG_IGN)) { |
no test coverage detected