Beispiel #1
0
 bool register_keeper(lock_service& z, const std::string& ip, int port){
   std::string path = JUBAKEEPER_BASE_PATH;
   z.create(path, "");
   {
     std::string path1;
     build_existence_path(path, ip, port, path1); 
     z.create(path1, "", true);
   }
   // set exit zlistener here
   pfi::lang::function <void()> f = &force_exit;
   z.push_cleanup(f);
   return true;
 }
Beispiel #2
0
  // zk -> name -> ip -> port -> bool
  bool register_actor(lock_service& z, const std::string& name, const std::string& ip, int port){

    std::string path = ACTOR_BASE_PATH + "/" + name;
    z.create(path, "");
    z.create(path + "/master_lock", "");
    path += "/nodes";
    z.create(path , "");
    {
      std::string path1;
      build_existence_path(path, ip, port, path1); 
      z.create(path1, "", true);
    }

    // set exit zlistener here
    pfi::lang::function <void()> f = &force_exit;
    z.push_cleanup(f);
    
    return true;
  }
TEST(util, build_existence_path) {
  string s;
  build_existence_path("/path/base", "127.0.0.1", 9199, s);
  EXPECT_EQ("/path/base/127.0.0.1_9199", s);
}