diff options
author | Mark Spruiell <mes@zeroc.com> | 2017-01-30 13:45:21 -0800 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2017-01-30 13:45:21 -0800 |
commit | 61270a10f980933cf582edb766f10c8ac6d86e8a (patch) | |
tree | 45ab4a7c2986954054fce613bc3c8f7967e7951e /ruby | |
parent | Fix slice2cpp build failure (diff) | |
download | ice-61270a10f980933cf582edb766f10c8ac6d86e8a.tar.bz2 ice-61270a10f980933cf582edb766f10c8ac6d86e8a.tar.xz ice-61270a10f980933cf582edb766f10c8ac6d86e8a.zip |
merging IceBridge into master
Diffstat (limited to 'ruby')
-rw-r--r-- | ruby/src/IceRuby/Connection.cpp | 46 | ||||
-rw-r--r-- | ruby/src/IceRuby/Util.cpp | 4 | ||||
-rw-r--r-- | ruby/test/Ice/acm/AllTests.rb | 46 | ||||
-rw-r--r-- | ruby/test/Ice/acm/Test.ice | 3 | ||||
-rw-r--r-- | ruby/test/Ice/binding/AllTests.rb | 20 | ||||
-rw-r--r-- | ruby/test/Ice/operations/BatchOneways.rb | 4 | ||||
-rw-r--r-- | ruby/test/Ice/timeout/AllTests.rb | 5 |
7 files changed, 104 insertions, 24 deletions
diff --git a/ruby/src/IceRuby/Connection.cpp b/ruby/src/IceRuby/Connection.cpp index 6b4b57efdc7..2c5f65a8434 100644 --- a/ruby/src/IceRuby/Connection.cpp +++ b/ruby/src/IceRuby/Connection.cpp @@ -46,14 +46,23 @@ IceRuby::createConnection(const Ice::ConnectionPtr& p) extern "C" VALUE -IceRuby_Connection_close(VALUE self, VALUE b) +IceRuby_Connection_close(VALUE self, VALUE mode) { ICE_RUBY_TRY { Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(self)); assert(p); - (*p)->close(RTEST(b)); + volatile VALUE type = callRuby(rb_path2class, "Ice::ConnectionClose"); + if(callRuby(rb_obj_is_instance_of, mode, type) != Qtrue) + { + throw RubyException(rb_eTypeError, + "value for 'mode' argument must be an enumerator of Ice.ConnectionClose"); + } + volatile VALUE modeValue = callRuby(rb_funcall, mode, rb_intern("to_i"), 0); + assert(TYPE(modeValue) == T_FIXNUM); + Ice::ConnectionClose cc = static_cast<Ice::ConnectionClose>(FIX2LONG(modeValue)); + (*p)->close(cc); } ICE_RUBY_CATCH return Qnil; @@ -76,6 +85,21 @@ IceRuby_Connection_flushBatchRequests(VALUE self) extern "C" VALUE +IceRuby_Connection_heartbeat(VALUE self) +{ + ICE_RUBY_TRY + { + Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(self)); + assert(p); + + (*p)->heartbeat(); + } + ICE_RUBY_CATCH + return Qnil; +} + +extern "C" +VALUE IceRuby_Connection_setACM(VALUE self, VALUE t, VALUE c, VALUE h) { ICE_RUBY_TRY @@ -221,6 +245,7 @@ IceRuby_Connection_getEndpoint(VALUE self) ICE_RUBY_CATCH return Qnil; } + extern "C" VALUE IceRuby_Connection_setBufferSize(VALUE self, VALUE r, VALUE s) @@ -241,6 +266,21 @@ IceRuby_Connection_setBufferSize(VALUE self, VALUE r, VALUE s) extern "C" VALUE +IceRuby_Connection_throwException(VALUE self) +{ + ICE_RUBY_TRY + { + Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(self)); + assert(p); + + (*p)->throwException(); + } + ICE_RUBY_CATCH + return Qnil; +} + +extern "C" +VALUE IceRuby_Connection_toString(VALUE self) { ICE_RUBY_TRY @@ -377,6 +417,7 @@ IceRuby::initConnection(VALUE iceModule) // rb_define_method(_connectionClass, "close", CAST_METHOD(IceRuby_Connection_close), 1); rb_define_method(_connectionClass, "flushBatchRequests", CAST_METHOD(IceRuby_Connection_flushBatchRequests), 0); + rb_define_method(_connectionClass, "heartbeat", CAST_METHOD(IceRuby_Connection_heartbeat), 0); rb_define_method(_connectionClass, "setACM", CAST_METHOD(IceRuby_Connection_setACM), 3); rb_define_method(_connectionClass, "getACM", CAST_METHOD(IceRuby_Connection_getACM), 0); rb_define_method(_connectionClass, "type", CAST_METHOD(IceRuby_Connection_type), 0); @@ -384,6 +425,7 @@ IceRuby::initConnection(VALUE iceModule) rb_define_method(_connectionClass, "getInfo", CAST_METHOD(IceRuby_Connection_getInfo), 0); rb_define_method(_connectionClass, "getEndpoint", CAST_METHOD(IceRuby_Connection_getEndpoint), 0); rb_define_method(_connectionClass, "setBufferSize", CAST_METHOD(IceRuby_Connection_setBufferSize), 2); + rb_define_method(_connectionClass, "throwException", CAST_METHOD(IceRuby_Connection_throwException), 0); rb_define_method(_connectionClass, "toString", CAST_METHOD(IceRuby_Connection_toString), 0); rb_define_method(_connectionClass, "to_s", CAST_METHOD(IceRuby_Connection_toString), 0); rb_define_method(_connectionClass, "inspect", CAST_METHOD(IceRuby_Connection_toString), 0); diff --git a/ruby/src/IceRuby/Util.cpp b/ruby/src/IceRuby/Util.cpp index 7fa1222fb06..84708f2dfb8 100644 --- a/ruby/src/IceRuby/Util.cpp +++ b/ruby/src/IceRuby/Util.cpp @@ -732,6 +732,10 @@ setExceptionMembers(const Ice::LocalException& ex, VALUE p) volatile VALUE v = createString(e.reason); callRuby(rb_iv_set, p, "@reason", v); } + catch(const Ice::ConnectionManuallyClosedException& e) + { + callRuby(rb_iv_set, p, "@graceful", e.graceful ? Qtrue : Qfalse); + } catch(const Ice::LocalException&) { // diff --git a/ruby/test/Ice/acm/AllTests.rb b/ruby/test/Ice/acm/AllTests.rb index 5c6b5e64f66..a147c616693 100644 --- a/ruby/test/Ice/acm/AllTests.rb +++ b/ruby/test/Ice/acm/AllTests.rb @@ -7,13 +7,10 @@ # # ********************************************************************** -def allTests(communicator) +def testSetACM(communicator, com) print "testing setACM/getACM... " STDOUT.flush - ref = "communicator:default -p 12010" - com = Test::RemoteCommunicatorPrx::uncheckedCast(communicator.stringToProxy(ref)) - adapter = com.createObjectAdapter(-1, -1, -1) initData = Ice::InitializationData.new @@ -44,14 +41,49 @@ def allTests(communicator) test(acm.close == Ice::ACMClose::CloseOnInvocationAndIdle) test(acm.heartbeat == Ice::ACMHeartbeat::HeartbeatAlways) - proxy.waitForHeartbeat(2) + proxy.startHeartbeatCount() + proxy.waitForHeartbeatCount(2) adapter.deactivate() testCommunicator.destroy() puts "ok" +end - print "shutting down... " +def testHeartbeatManual(communicator, com) + print "testing manual heartbeats... " STDOUT.flush - com.shutdown() + + adapter = com.createObjectAdapter(10, -1, 0) + + initData = Ice::InitializationData.new + initData.properties = communicator.getProperties().clone() + initData.properties.setProperty("Ice.ACM.Timeout", "10") + initData.properties.setProperty("Ice.ACM.Client.Timeout", "10") + initData.properties.setProperty("Ice.ACM.Client.Close", "0") + initData.properties.setProperty("Ice.ACM.Client.Heartbeat", "0") + testCommunicator = Ice::initialize(initData) + proxy = Test::TestIntfPrx::uncheckedCast(testCommunicator.stringToProxy(adapter.getTestIntf().ice_toString())) + con = proxy.ice_getConnection() + + proxy.startHeartbeatCount() + con.heartbeat() + con.heartbeat() + con.heartbeat() + con.heartbeat() + con.heartbeat() + proxy.waitForHeartbeatCount(5) + + adapter.deactivate() + testCommunicator.destroy() puts "ok" end + +def allTests(communicator) + ref = "communicator:default -p 12010" + com = Test::RemoteCommunicatorPrx::uncheckedCast(communicator.stringToProxy(ref)) + + testSetACM(communicator, com) + testHeartbeatManual(communicator, com) + + com.shutdown() +end diff --git a/ruby/test/Ice/acm/Test.ice b/ruby/test/Ice/acm/Test.ice index 5ab98180dd3..d78abd6eb0f 100644 --- a/ruby/test/Ice/acm/Test.ice +++ b/ruby/test/Ice/acm/Test.ice @@ -17,7 +17,8 @@ interface TestIntf void sleep(int seconds); void sleepAndHold(int seconds); void interruptSleep(); - void waitForHeartbeat(int count); + void startHeartbeatCount(); + void waitForHeartbeatCount(int count); }; interface RemoteObjectAdapter diff --git a/ruby/test/Ice/binding/AllTests.rb b/ruby/test/Ice/binding/AllTests.rb index f4c32a3a999..605063c96e4 100644 --- a/ruby/test/Ice/binding/AllTests.rb +++ b/ruby/test/Ice/binding/AllTests.rb @@ -92,7 +92,7 @@ def allTests(communicator) if names.include?(name) names.delete(name) end - test1.ice_getConnection().close(false) + test1.ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) end # @@ -113,7 +113,7 @@ def allTests(communicator) test(i == nRetry) for a in adapters - a.getTestIntf().ice_getConnection().close(false) + a.getTestIntf().ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) end # @@ -139,7 +139,7 @@ def allTests(communicator) if names.include?(name) names.delete(name) end - test1.ice_getConnection().close(false) + test1.ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) end # @@ -171,7 +171,7 @@ def allTests(communicator) if names.include?(name) names.delete(name) end - t.ice_getConnection().close(false) + t.ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) end t = Test::TestIntfPrx::uncheckedCast(t.ice_endpointSelection(Ice::EndpointSelectionType::Random)) @@ -185,7 +185,7 @@ def allTests(communicator) if names.include?(name) names.delete(name) end - t.ice_getConnection().close(false) + t.ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) end deactivate(com, adapters) @@ -250,14 +250,14 @@ def allTests(communicator) i = i + 1 end test(i == nRetry) - t.ice_getConnection().close(false) + t.ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) adapters.push(com.createObjectAdapter("Adapter35", endpoints[1].toString())) i = 0 while i < nRetry and t.getAdapterName() == "Adapter35" i = i + 1 end test(i == nRetry) - t.ice_getConnection().close(false) + t.ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) adapters.push(com.createObjectAdapter("Adapter34", endpoints[0].toString())) i = 0 while i < nRetry and t.getAdapterName() == "Adapter34" @@ -442,7 +442,7 @@ def allTests(communicator) t = createTestIntfPrx(adapters) for i in 0...5 test(t.getAdapterName() == "Adapter82") - t.ice_getConnection().close(false) + t.ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) end testSecure = Test::TestIntfPrx::uncheckedCast(t.ice_secure(true)) @@ -457,14 +457,14 @@ def allTests(communicator) for i in 0...5 test(t.getAdapterName() == "Adapter81") - t.ice_getConnection().close(false) + t.ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) end com.createObjectAdapter("Adapter83", (t.ice_getEndpoints()[1]).toString()) # Reactive tcp OA. for i in 0...5 test(t.getAdapterName() == "Adapter83") - t.ice_getConnection().close(false) + t.ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) end com.deactivateObjectAdapter(adapters[0]) diff --git a/ruby/test/Ice/operations/BatchOneways.rb b/ruby/test/Ice/operations/BatchOneways.rb index 042899d3d6b..99b2225f61b 100644 --- a/ruby/test/Ice/operations/BatchOneways.rb +++ b/ruby/test/Ice/operations/BatchOneways.rb @@ -33,7 +33,7 @@ def batchOneways(p) batch.ice_ping() batch2.ice_ping() batch.ice_flushBatchRequests() - batch.ice_getConnection().close(false) + batch.ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) batch.ice_ping() batch2.ice_ping() @@ -41,7 +41,7 @@ def batchOneways(p) batch2.ice_getConnection() batch.ice_ping() - batch.ice_getConnection().close(false) + batch.ice_getConnection().close(Ice::ConnectionClose::CloseGracefullyAndWait) batch.ice_ping() batch2.ice_ping() diff --git a/ruby/test/Ice/timeout/AllTests.rb b/ruby/test/Ice/timeout/AllTests.rb index 05746528fc6..6c9ccc7ea55 100644 --- a/ruby/test/Ice/timeout/AllTests.rb +++ b/ruby/test/Ice/timeout/AllTests.rb @@ -98,7 +98,7 @@ def allTests(communicator) to = Test::TimeoutPrx.checkedCast(obj.ice_timeout(100)) connection = to.ice_getConnection() timeout.holdAdapter(500) - connection.close(false) + connection.close(Ice::ConnectionClose::CloseGracefullyAndWait) begin connection.getInfo() # getInfo() doesn't throw in the closing state. rescue Ice::LocalException @@ -108,8 +108,9 @@ def allTests(communicator) begin connection.getInfo() test(false) - rescue Ice::CloseConnectionException + rescue Ice::ConnectionManuallyClosedException => ex # Expected. + test(ex.graceful) end timeout.op() # Ensure adapter is active. puts "ok" |