Esempio n. 1
0
  static void test_common()
  {
    log::asio_logger lgr;
    log::logger_t lg = boost::bind(&gce::log::asio_logger::output, &lgr, _arg1, "");
    try
    {
      std::size_t echo_num = 100;

      attributes attrs;
      attrs.lg_ = lg;
      attrs.id_ = atom("two");
      context ctx2(attrs);
      threaded_actor base2 = spawn(ctx2);

      svcid_t guidsys = make_svcid("cachesys", "cachesys");

      connect(base2, "cachesys", "tcp://127.0.0.1:20001");
      base2.sleep_for(millisecs(100));

      for(int i = 0; i < test_count; i++)
      {
          p::xs2ds_entity_req req;
          req.req_guid = 1;
          base2->send(guidsys, XS2DS_ENTITY_REQ, req);
          p::ds2xs_entity_ack ack;
          base2->match(DS2XS_ENTITY_ACK).recv(ack);
          //std::cout << "received, index: " << ack.data << std::endl;
          GCE_INFO(lg) << i << " "<< ack.data << "\n";
      }
    }
    catch (std::exception& ex)
    {
      std::cerr << ex.what() << std::endl;
    }
  }
Esempio n. 2
0
  static void test_base()
  {
    try
    {
      std::size_t echo_num = 10;

      gce::log::asio_logger lg;
      attributes attrs;
      attrs.lg_ = boost::bind(&gce::log::asio_logger::output, &lg, _arg1, "");
      
      attrs.id_ = atom("router");
      context ctx(attrs);
      attrs.id_ = atom("one");
      context ctx1(attrs);
      attrs.id_ = atom("two");
      context ctx2(attrs);
      
      threaded_actor base = spawn(ctx);
      threaded_actor base1 = spawn(ctx1);
      threaded_actor base2 = spawn(ctx2);
      
      netopt_t opt = make_netopt();
      opt.is_router = 1;
      gce::bind(base, "tcp://127.0.0.1:14923", remote_func_list_t(), opt);

      spawn(base1, "test_lua_actor/services.lua", monitored);
      spawn(base2, "test_lua_actor/services.lua", monitored);

      opt.reconn_period = seconds(1);
      connect(base1, "router", "tcp://127.0.0.1:14923", opt);
      connect(base2, "router", "tcp://127.0.0.1:14923", opt);
      base2.sleep_for(millisecs(200));

      for (std::size_t i=0; i<echo_num; ++i)
      {
        base1->send("echo_svc", "echo");
        base1->recv("echo");
      }

      base1->send(make_svcid("one", "echo_svc"), "end");
      base1->send(make_svcid("two", "echo_svc"), "end");

      base1->recv(exit);
      base2->recv(exit);
    }
    catch (std::exception& ex)
    {
      std::cerr << ex.what() << std::endl;
    }
  }
Esempio n. 3
0
  static void test_common()
  {
    try
    {
      context ctx;
      threaded_actor base = spawn(ctx);

      aid_t base_id = base.get_aid();
      aid_t aid1 = spawn(base, boost::bind(&match_recver_ut::my_actor, _arg1, base_id), monitored);
      spawn(base, boost::bind(&match_recver_ut::my_actor, _arg1, aid_t()), monitored);

      message msg;
      pattern patt;
      patt.add_match("timeout");
      patt.timeout_ = millisecs(1);
      aid_t sender = base.recv(msg, patt);
      GCE_VERIFY(sender == aid_nil);

      int i = -1;
      base->recv("catch", guard(aid1), i);
      GCE_VERIFY(i == 0);
      std::cout << "catch " << i << std::endl;
      base->match("catch").guard(aid1).recv(i);
      GCE_VERIFY(i == 1);
      std::cout << "catch " << i << std::endl;

      resp_t res = base->request(aid1, "resp", i);
      errcode_t ec;
      base->match(res).guard(ec).raw(msg).respond(i);
      GCE_VERIFY(ec);
      GCE_VERIFY(msg.get_type() == exit);

      base->match("not_catch").guard(aid1, ec).recv(i);
      GCE_VERIFY(ec);
    }
    catch (std::exception& ex)
    {
      std::cerr << ex.what() << std::endl;
    }
  }
Esempio n. 4
0
void ElapsedTimer::print() { 
  lprintf("%2.2f (ms)", millisecs()); 
}