diff options
author | Benoit Foucher <benoit@zeroc.com> | 2017-02-06 11:17:34 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2017-02-06 11:17:34 +0100 |
commit | 18ab8207bd14def950fd399c60d9ee54fab75d3b (patch) | |
tree | a82af333127184acc6be6e0969919cb20be5e8b3 /ruby | |
parent | Fixed ICE-7548 - getAdminProxy no longer returns 0 if synchronization is in p... (diff) | |
download | ice-18ab8207bd14def950fd399c60d9ee54fab75d3b.tar.bz2 ice-18ab8207bd14def950fd399c60d9ee54fab75d3b.tar.xz ice-18ab8207bd14def950fd399c60d9ee54fab75d3b.zip |
Fixed ICE-7169 and ICE-7375 - add option to specify if batch requests flushed with the communicator/connection should be compressed
Diffstat (limited to 'ruby')
-rw-r--r-- | ruby/src/IceRuby/Communicator.cpp | 16 | ||||
-rw-r--r-- | ruby/src/IceRuby/Connection.cpp | 17 | ||||
-rw-r--r-- | ruby/test/Ice/operations/BatchOneways.rb | 4 |
3 files changed, 29 insertions, 8 deletions
diff --git a/ruby/src/IceRuby/Communicator.cpp b/ruby/src/IceRuby/Communicator.cpp index 232092dd9bd..cb7c24fd9a5 100644 --- a/ruby/src/IceRuby/Communicator.cpp +++ b/ruby/src/IceRuby/Communicator.cpp @@ -613,12 +613,22 @@ IceRuby_Communicator_setDefaultLocator(VALUE self, VALUE locator) extern "C" VALUE -IceRuby_Communicator_flushBatchRequests(VALUE self) +IceRuby_Communicator_flushBatchRequests(VALUE self, VALUE compress) { ICE_RUBY_TRY { Ice::CommunicatorPtr p = getCommunicator(self); - p->flushBatchRequests(); + + volatile VALUE type = callRuby(rb_path2class, "Ice::CompressBatch"); + if(callRuby(rb_obj_is_instance_of, compress, type) != Qtrue) + { + throw RubyException(rb_eTypeError, + "value for 'compress' argument must be an enumerator of Ice::CompressBatch"); + } + volatile VALUE compressValue = callRuby(rb_funcall, compress, rb_intern("to_i"), 0); + assert(TYPE(compressValue) == T_FIXNUM); + Ice::CompressBatch cb = static_cast<Ice::CompressBatch>(FIX2LONG(compressValue)); + p->flushBatchRequests(cb); } ICE_RUBY_CATCH return Qnil; @@ -651,7 +661,7 @@ IceRuby::initCommunicator(VALUE iceModule) rb_define_method(_communicatorClass, "setDefaultRouter", CAST_METHOD(IceRuby_Communicator_setDefaultRouter), 1); rb_define_method(_communicatorClass, "getDefaultLocator", CAST_METHOD(IceRuby_Communicator_getDefaultLocator), 0); rb_define_method(_communicatorClass, "setDefaultLocator", CAST_METHOD(IceRuby_Communicator_setDefaultLocator), 1); - rb_define_method(_communicatorClass, "flushBatchRequests", CAST_METHOD(IceRuby_Communicator_flushBatchRequests), 0); + rb_define_method(_communicatorClass, "flushBatchRequests", CAST_METHOD(IceRuby_Communicator_flushBatchRequests), 1); } Ice::CommunicatorPtr diff --git a/ruby/src/IceRuby/Connection.cpp b/ruby/src/IceRuby/Connection.cpp index 2c5f65a8434..9c0a4b76ed1 100644 --- a/ruby/src/IceRuby/Connection.cpp +++ b/ruby/src/IceRuby/Connection.cpp @@ -57,7 +57,7 @@ IceRuby_Connection_close(VALUE self, VALUE mode) 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"); + "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); @@ -70,14 +70,23 @@ IceRuby_Connection_close(VALUE self, VALUE mode) extern "C" VALUE -IceRuby_Connection_flushBatchRequests(VALUE self) +IceRuby_Connection_flushBatchRequests(VALUE self, VALUE compress) { ICE_RUBY_TRY { Ice::ConnectionPtr* p = reinterpret_cast<Ice::ConnectionPtr*>(DATA_PTR(self)); assert(p); - (*p)->flushBatchRequests(); + volatile VALUE type = callRuby(rb_path2class, "Ice::CompressBatch"); + if(callRuby(rb_obj_is_instance_of, compress, type) != Qtrue) + { + throw RubyException(rb_eTypeError, + "value for 'compress' argument must be an enumerator of Ice::CompressBatch"); + } + volatile VALUE compressValue = callRuby(rb_funcall, compress, rb_intern("to_i"), 0); + assert(TYPE(compressValue) == T_FIXNUM); + Ice::CompressBatch cb = static_cast<Ice::CompressBatch>(FIX2LONG(compressValue)); + (*p)->flushBatchRequests(cb); } ICE_RUBY_CATCH return Qnil; @@ -416,7 +425,7 @@ IceRuby::initConnection(VALUE iceModule) // Instance methods. // 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, "flushBatchRequests", CAST_METHOD(IceRuby_Connection_flushBatchRequests), 1); 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); diff --git a/ruby/test/Ice/operations/BatchOneways.rb b/ruby/test/Ice/operations/BatchOneways.rb index 99b2225f61b..1935c52f1e8 100644 --- a/ruby/test/Ice/operations/BatchOneways.rb +++ b/ruby/test/Ice/operations/BatchOneways.rb @@ -13,6 +13,8 @@ def batchOneways(p) batch = Test::MyClassPrx::uncheckedCast(p.ice_batchOneway()) batch.ice_flushBatchRequests() # Empty flush + batch.ice_getConnection().flushBatchRequests(Ice::CompressBatch::BasedOnProxy) + batch.ice_getCommunicator().flushBatchRequests(Ice::CompressBatch::BasedOnProxy) p.opByteSOnewayCallCount() # Reset the call count @@ -26,7 +28,7 @@ def batchOneways(p) sleep(0.01) end - batch.ice_getConnection().flushBatchRequests() + batch.ice_getConnection().flushBatchRequests(Ice::CompressBatch::BasedOnProxy) batch2 = Test::MyClassPrx::uncheckedCast(p.ice_batchOneway()) |