diff options
Diffstat (limited to 'cpp/test/Ice/retry/TestI.cpp')
-rw-r--r-- | cpp/test/Ice/retry/TestI.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/cpp/test/Ice/retry/TestI.cpp b/cpp/test/Ice/retry/TestI.cpp index dbac9886439..b3545fa4c7a 100644 --- a/cpp/test/Ice/retry/TestI.cpp +++ b/cpp/test/Ice/retry/TestI.cpp @@ -9,14 +9,76 @@ #include <Ice/Ice.h> #include <TestI.h> +#include <SystemFailure.h> + +namespace +{ + +const int nRetry = 4; // See Ice.RetryIntervals configuration in Client.cpp/Collocated.cpp + +} + +RetryI::RetryI() : _counter(0) +{ +} void RetryI::op(bool kill, const Ice::Current& current) { if(kill) { + if(current.con) + { + current.con->close(true); + } + else + { + throw Ice::ConnectionLostException(__FILE__, __LINE__); + } + } +} + +int +RetryI::opIdempotent(int counter, const Ice::Current& current) +{ + if(counter + nRetry > _counter) + { + ++_counter; + if(current.con) + { + current.con->close(true); + } + else + { + throw Ice::ConnectionLostException(__FILE__, __LINE__); + } + } + return _counter; +} + +void +RetryI::opNotIdempotent(int counter, const Ice::Current& current) +{ + if(_counter != counter) + { + return; + } + + ++_counter; + if(current.con) + { current.con->close(true); } + else + { + throw Ice::ConnectionLostException(__FILE__, __LINE__); + } +} + +void +RetryI::opSystemException(const Ice::Current&) +{ + throw SystemFailure(__FILE__, __LINE__); } void |