summaryrefslogtreecommitdiff
path: root/TAO/tests/Oneway_Timeouts/client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/tests/Oneway_Timeouts/client.cpp')
-rw-r--r--TAO/tests/Oneway_Timeouts/client.cpp137
1 files changed, 56 insertions, 81 deletions
diff --git a/TAO/tests/Oneway_Timeouts/client.cpp b/TAO/tests/Oneway_Timeouts/client.cpp
index 36be9d30ffe..8a3a74950d1 100644
--- a/TAO/tests/Oneway_Timeouts/client.cpp
+++ b/TAO/tests/Oneway_Timeouts/client.cpp
@@ -3,7 +3,7 @@
#include "tao/Messaging/Messaging.h"
#include "tao/AnyTypeCode/TAOA.h"
#include "tao/AnyTypeCode/Any.h"
-//#include "tao/IIOP_Connector.h"
+#include "tao/IIOP_Connector.h"
#include "ace/streams.h"
#include "ace/High_Res_Timer.h"
@@ -17,7 +17,7 @@ using namespace PortableServer;
namespace
{
const char *non_existent_ior = "corbaloc:iiop:1.2@63.246.9.65:12345/test";
- const int TIME_THRESHOLD = 100; //ms
+ const int TIME_THRESHOLD = 50; //ms
int request_timeout = 0;
Messaging::SyncScope sync_scope;
@@ -42,27 +42,16 @@ namespace
bool retry_transients = false;
bool retry_timeouts = false;
- void print_usage (const char *argv0)
+ void print_usage ()
{
- ACE_ERROR ((LM_ERROR,
- "%s [-request_timeout ms=0] "
- "[-connect_timeout ms=0] "
- "[-request_interval ms=100] "
- "[-run_orb_delay ms=0] "
- "[-run_orb_time ms=0] "
- "[-max_request_time ms=0] "
- "[-num_requests n=10] "
- "[-use_twoway] "
- "[-retry_transients] "
- "[-retry_timeouts] "
- "[-use_sleep] "
- "[-force_timeout] "
- "[-force_connect] "
- "[-buffer_count n=0]"
- "[-buffer_bytes n=0] "
- "[-buffer_timeout ms=0] "
- "[-sync delayed|eager|none]\n",
- argv0));
+ cout << "client [-request_timeout ms=0] [-connect_timeout ms=0] "
+ "[-request_interval ms=100]\n\t[-run_orb_delay ms=0] "
+ "[-run_orb_time ms=0] [-max_request_time ms=0]\n"
+ "\t[-num_requests n=10] [-use_twoway] [-retry_transients] "
+ "[-retry_timeouts]\n"
+ "\t[-use_sleep] [-force_timeout] [-force_connect] [-buffer_count n=0]\n"
+ "\t[-buffer_bytes n=0] [-buffer_timeout ms=0] [-sync delayed|eager|none]"
+ << endl;
}
bool parse_command_line (int ac, char *av[])
@@ -185,7 +174,7 @@ namespace
}
else
{
- print_usage (av[0]);
+ print_usage ();
return false;
}
@@ -193,9 +182,9 @@ namespace
}
else
{
- ACE_ERROR ((LM_ERROR, "Error: Unknown argument \"%s\"\n",
- args.get_current ()));
- print_usage (av[0]);
+ cerr << "Error: Unknown argument \""
+ << args.get_current () << "\"" << endl;
+ print_usage ();
return false;
}
@@ -339,7 +328,7 @@ int main (int ac, char *av[])
{
tmp_tester = Tester::_narrow (obj.in ());
tmp_tester->test2 (-2);
- ACE_DEBUG ((LM_DEBUG, "Connected...\n"));
+ cout << "Connected..." << endl;
}
else
tmp_tester = Tester::_unchecked_narrow (obj.in ());
@@ -352,7 +341,6 @@ int main (int ac, char *av[])
for (; i < num_requests; ++i)
{
- ACE_DEBUG ((LM_DEBUG, "Updating 'before' time\n"));
before = ACE_High_Res_Timer::gettimeofday_hr ();
try
{
@@ -368,23 +356,21 @@ int main (int ac, char *av[])
}
catch (CORBA::TRANSIENT&)
{
- ACE_DEBUG ((LM_DEBUG,
- "Transient exception during test () invocation %d\n",
- i));
- if (retry_transients)
- ACE_DEBUG ((LM_DEBUG,"retrying\n"));
- else
- throw;
+ cerr << "Transient exception during test () invocation " << i << endl;
+ if (! retry_transients)
+ {
+ throw;
+ }
+
}
catch (CORBA::TIMEOUT&)
{
- ACE_DEBUG ((LM_DEBUG,
- "Timeout exception during test () invocation %d\n",
- i));
- if (retry_timeouts)
- ACE_DEBUG ((LM_DEBUG,"retrying\n"));
- else
- throw;
+ cerr << "Timeout exception during test () invocation " << i << endl;
+ if (! retry_timeouts)
+ {
+ throw;
+ }
+
}
++num_requests_sent;
@@ -393,14 +379,13 @@ int main (int ac, char *av[])
if (max_request_time > 0 &&
(after - before).msec () > max_request_time)
{
- ACE_ERROR_RETURN ((LM_ERROR,
- "Error: test() took %d ms, max is %d ms\n",
- (after - before).msec (), max_request_time),
- 1);
+ cerr << "Error : test () took " << (after - before).msec ()
+ << endl;
+ return 1;
}
- ACE_DEBUG ((LM_DEBUG, "c%d\n", i));
+ cout << 'c' << i << endl;
if (request_interval > 0)
{
ACE_Time_Value tv (0, request_interval * 1000);
@@ -422,8 +407,6 @@ int main (int ac, char *av[])
}
}
- ACE_DEBUG ((LM_DEBUG,"request loop complete\n"));
-
if (run_orb_delay > 0)
{
@@ -438,14 +421,8 @@ int main (int ac, char *av[])
orb->run (tv);
}
- ACE_DEBUG ((LM_DEBUG,"Sending synch request to shutdown server\n"));
- if (force_timeout)
- // we have one more invocation that may time out.
- before = ACE_High_Res_Timer::gettimeofday_hr ();
- use_twoway = true;
- use_sync_scope = false;
- // Let the server know we're finished. This will timeout if
- // force_timeout is true.
+
+ // Let the server know we're finished.
tester->test2 (-1);
orb->shutdown (1);
@@ -454,18 +431,19 @@ int main (int ac, char *av[])
if (force_timeout)
{
- ACE_ERROR_RETURN ((LM_ERROR,
- "Error: Connection did not time out.\n"),
- 1);
+ cerr << "Error: Connection did not timeout." << endl;
+ return 1;
}
+
return 0;
+
}
catch (CORBA::TRANSIENT &ex)
{
- ACE_DEBUG ((LM_DEBUG, "caught transient exception\n"));
if (force_timeout)
{
+ ACE_DEBUG ((LM_DEBUG, "caught exception\n"));
ACE_Time_Value after = ACE_High_Res_Timer::gettimeofday_hr ();
long ms = (after - before).msec ();
if ( (use_twoway || !use_sync_scope)
@@ -478,9 +456,8 @@ int main (int ac, char *av[])
{
if (ms > TIME_THRESHOLD)
{
- ACE_ERROR_RETURN ((LM_ERROR,
- "Error: Buffered request took %dms\n",
- ms),1);
+ cerr << "Error: Buffered request took " << ms << endl;
+ return 1;
}
ms = num_requests_sent * request_interval;
@@ -489,22 +466,20 @@ int main (int ac, char *av[])
if (std::abs (static_cast<int>(ms - connect_timeout))
> TIME_THRESHOLD)
{
- ACE_ERROR_RETURN ((LM_ERROR,
- "Error: Timeout expected in %d ms, "
- "but took %d ms\n", connect_timeout, ms),
- 1);
+ cerr << "Error: Timeout expected in " << connect_timeout
+ << "ms, but took " << ms << "ms" << endl;
+ return 1;
}
return 0;
}
else
{
- ACE_ERROR_RETURN ((LM_ERROR, "Error: Unexpected\n"), 1);
+ cerr << "Error: Unexpected transient\n" << ex << endl;
}
}
catch (CORBA::TIMEOUT &ex)
{
- ACE_DEBUG ((LM_DEBUG, "caught timeout exception\n"));
if (force_timeout)
{
ACE_Time_Value after = ACE_High_Res_Timer::gettimeofday_hr ();
@@ -519,9 +494,8 @@ int main (int ac, char *av[])
{
if (ms > TIME_THRESHOLD)
{
- ACE_ERROR_RETURN ((LM_ERROR,
- "Error: Buffered request took %d ms\n",
- ms),1);
+ cerr << "Error: Buffered request took " << ms << endl;
+ return 1;
}
ms = num_requests_sent * request_interval;
@@ -530,25 +504,26 @@ int main (int ac, char *av[])
if (std::abs (static_cast<int>(ms - connect_timeout))
> TIME_THRESHOLD)
{
- ACE_ERROR_RETURN ((LM_ERROR,
- "Error: Timeout expected in %d ms, "
- "but took %d ms\n", connect_timeout, ms),
- 1);
+ cerr << "Error: Timeout expected in " << connect_timeout
+ << "ms, but took " << ms << "ms" << endl;
+ return 1;
}
return 0;
}
else
{
- ACE_ERROR_RETURN ((LM_ERROR, "Error: Unexpected\n"), 1);
+ cerr << "Error: Unexpected timeout\n" << ex << endl;
}
}
catch (Exception &ex)
{
- ACE_ERROR ((LM_ERROR, "client: %s\n\nLast operation took %d ms.\n",
- ex._name(),
- (ACE_High_Res_Timer::gettimeofday_hr () - before).msec ()));
+ cerr << "client: " << ex << endl;
+ cerr << "\nLast operation took "
+ << (ACE_High_Res_Timer::gettimeofday_hr () - before).msec ()
+ << "ms"
+ << endl;
}
return 1;