Example #1
0
void
do_primary_test (CORBA::Object_var &server,
                 Messaging::ReplyHandler_var &callback)
{
  try
    {

      CORBA::Request_var req = server->_request("do_forward");

      if (CORBA::is_nil (server.in ()))
        {
          ACE_ERROR ((LM_ERROR,
                      "Object reference <%s> is nil.\n",
                      ior));
          return;
        }

      ACE_DEBUG((LM_DEBUG,"Client sending test string\n"));
      CORBA::String_var test_string = CORBA::string_dup ("123 look at me");
      req->add_in_arg ("text") <<=
        CORBA::Any::from_string(test_string.in(),30);
      req->sendc(callback.in());
    }
  catch (CORBA::Exception &ex)
    {
      ACE_ERROR ((LM_ERROR,
                  "Client caught exception: %C\n",ex._name()));
    }
}
Example #2
0
void
test_octet_seq (const CORBA::Object_var object)
{
  ACE_Sample_History history (niterations);

  Test::octet_load ol (sz);
  ol.length (sz);

  ACE_hrtime_t test_start = ACE_OS::gethrtime ();
  for (int i = 0; i < niterations; ++i)
    {
      ACE_hrtime_t start = ACE_OS::gethrtime ();
      Test::Timestamp start_time = static_cast <Test::Timestamp> (start);

      CORBA::Request_var request =
        object->_request ("test_octet_method");

      request->add_in_arg("octet_load") <<= ol;
      request->add_in_arg("send_time") <<= start_time;

      request->set_return_type (CORBA::_tc_ulonglong);
      request->invoke ();

      ACE_hrtime_t now = ACE_OS::gethrtime ();
      history.sample (now - start);
    }

  ACE_hrtime_t test_end = ACE_OS::gethrtime ();

  ACE_DEBUG ((LM_DEBUG, "test finished\n"));

  ACE_DEBUG ((LM_DEBUG, "High resolution timer calibration...."));
  ACE_High_Res_Timer::global_scale_factor_type gsf =
    ACE_High_Res_Timer::global_scale_factor ();
  ACE_DEBUG ((LM_DEBUG, "done\n"));

  if (do_dump_history)
    {
      history.dump_samples (ACE_TEXT("HISTORY"), gsf);
    }

  ACE_Basic_Stats stats;
  history.collect_basic_stats (stats);
  stats.dump_results (ACE_TEXT("Total"), gsf);

  ACE_Throughput_Stats::dump_throughput (ACE_TEXT("Total"), gsf,
                                         test_end - test_start,
                                         stats.samples_count ());
}
Example #3
0
int do_shutdown_test (CORBA::Object_var &server)
{
  ACE_DEBUG ((LM_DEBUG,
              "[client] invoking shutdown on the server \n"));
  try
    {
      CORBA::Request_var req = server->_request("shutdown");
      req->invoke();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Client: exception caught during shutdown - ");
      return 1;
    }
  return 0;
}
Example #4
0
File: client.cpp Project: CCJY/ATCD
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  int priority =
    (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO)
     + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2;
  // Enable FIFO scheduling, e.g., RT scheduling class on Solaris.

  if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO,
                                              priority,
                                              ACE_SCOPE_PROCESS)) != 0)
    {
      if (ACE_OS::last_error () == EPERM)
        {
          ACE_DEBUG ((LM_DEBUG,
                      "client (%P|%t): user is not superuser, "
                      "test runs in time-shared class\n"));
        }
      else
        ACE_ERROR ((LM_ERROR,
                    "client (%P|%t): sched_params failed\n"));
    }

  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      if (parse_args (argc, argv) != 0)
        return 1;

      CORBA::Object_var object =
        orb->string_to_object (ior);

      if (CORBA::is_nil (object.in ()))
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Nil CORBA::Object reference <%s>\n",
                             ior),
                            1);
        }

      for (int j = 0; j < 100; ++j)
        {
          CORBA::Request_var request =
            object->_request ("test_method");

          CORBA::ULongLong dummy = 0;
          request->add_in_arg("send_time") <<= dummy;

          request->set_return_type (CORBA::_tc_ulonglong);
          request->invoke ();
        }

      ACE_Sample_History history (niterations);

      ACE_hrtime_t test_start = ACE_OS::gethrtime ();
      for (int i = 0; i < niterations; ++i)
        {
          ACE_hrtime_t start = ACE_OS::gethrtime ();

          CORBA::Request_var request =
            object->_request ("test_method");

          CORBA::ULongLong start_time = static_cast <CORBA::ULongLong> (start);
          request->add_in_arg("send_time") <<= start_time;

          request->set_return_type (CORBA::_tc_ulonglong);
          request->invoke ();

          ACE_hrtime_t now = ACE_OS::gethrtime ();
          history.sample (now - start);
        }

      ACE_hrtime_t test_end = ACE_OS::gethrtime ();

      ACE_DEBUG ((LM_DEBUG, "test finished\n"));

      ACE_DEBUG ((LM_DEBUG, "High resolution timer calibration...."));
      ACE_High_Res_Timer::global_scale_factor_type gsf =
        ACE_High_Res_Timer::global_scale_factor ();
      ACE_DEBUG ((LM_DEBUG, "done\n"));

      if (do_dump_history)
        {
          history.dump_samples (ACE_TEXT("HISTORY"), gsf);
        }

      ACE_Basic_Stats stats;
      history.collect_basic_stats (stats);
      stats.dump_results (ACE_TEXT("Total"), gsf);

      ACE_Throughput_Stats::dump_throughput (ACE_TEXT("Total"), gsf,
                                             test_end - test_start,
                                             stats.samples_count ());

      if (do_shutdown)
        {
          CORBA::Request_var request =
            object->_request ("shutdown");

          request->invoke ();

        }
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      return 1;
    }

  return 0;
}
Example #5
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);

      if (parse_args (argc, argv) != 0)
        return 1;

      CORBA::Object_var obj = orb->string_to_object(ior);

      const char* the_string = 0;

      ACE_DEBUG ((LM_INFO, "(%P|%t) - #### Synchronous twoway DII\n"));

      CORBA::Request_var req = obj->_request ("get_string");
      req->set_return_type (CORBA::_tc_string);

      req->invoke ();
      req->return_value () >>= the_string;

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
                  the_string));

      ACE_DEBUG ((LM_INFO, "(%P|%t) - #### Deferred twoway DII (using get_response())\n"));

      req = obj->_request ("get_string");
      req->set_return_type (CORBA::_tc_string);

      req->send_deferred ();
      ACE_DEBUG ((LM_INFO, "(%P|%t) - Get response...\n"));
      req->get_response ();
      req->return_value () >>= the_string;

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
                  the_string));

      ACE_DEBUG ((LM_INFO, "(%P|%t) - #### Deferred twoway DII (using poll_response())\n"));

      req = obj->_request ("get_string");
      req->set_return_type (CORBA::_tc_string);

      req->send_deferred ();
      do {
        ACE_OS::sleep(1);
        ACE_DEBUG ((LM_INFO, "(%P|%t) - Polling...\n"));
      } while (!req->poll_response ());
      req->return_value () >>= the_string;

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
                  the_string));

      ACE_DEBUG ((LM_INFO, "(%P|%t) - #### Oneway shutdown DII\n"));

      req = obj->_request ("shutdown");
      req->send_oneway ();

      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      return 1;
    }

  return 0;
}
Example #6
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  int priority =
    (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO)
     + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2;
  // Enable FIFO scheduling, e.g., RT scheduling class on Solaris.

  if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO,
                                              priority,
                                              ACE_SCOPE_PROCESS)) != 0)
    {
      if (ACE_OS::last_error () == EPERM)
        {
          ACE_DEBUG ((LM_DEBUG,
                      "client (%P|%t): user is not superuser, "
                      "test runs in time-shared class\n"));
        }
      else
        ACE_ERROR ((LM_ERROR,
                    "client (%P|%t): sched_params failed\n"));
    }

  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      if (parse_args (argc, argv) != 0)
        return 1;

      CORBA::Object_var object =
        orb->string_to_object (ior);

      if (CORBA::is_nil (object.in ()))
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Nil CORBA::Object reference <%s>\n",
                             ior),
                            1);
        }

      Test::octet_load oc;

      for (int j = 0; j < 100; ++j)
        {
          CORBA::Request_var request =
            object->_request ("test_octet_method");

          Test::Timestamp dummy = 0;
          request->add_in_arg("octet_load") <<= oc;
          request->add_in_arg("send_time") <<= dummy;

          request->set_return_type (CORBA::_tc_ulonglong);
          request->invoke ();
        }

      // Test various sequence types

      if (ACE_OS::strcmp (data_type, ACE_TEXT("octet")) == 0 )
        {
          test_octet_seq (object);
        }
      else if (ACE_OS::strcmp (data_type, ACE_TEXT("char")) == 0)
        {
          test_char_seq (object);
        }
      else if (ACE_OS::strcmp (data_type, ACE_TEXT("long")) == 0)
        {
          test_long_seq (object);
        }
      else if (ACE_OS::strcmp (data_type, ACE_TEXT("short")) == 0)
        {
          test_short_seq (object);
        }
      else if (ACE_OS::strcmp (data_type, ACE_TEXT("double")) == 0)
        {
          test_double_seq (object);
        }
      else if (ACE_OS::strcmp (data_type, ACE_TEXT("longlong")) == 0)
        {
          test_longlong_seq (object);
        }

      if (do_shutdown)
        {
          CORBA::Request_var request =
            object->_request ("shutdown");

          request->invoke ();
        }
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      return 1;
    }

  return 0;
}