avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1414979 - in /avro/trunk: CHANGES.txt lang/ruby/lib/avro/ipc.rb
Date Wed, 28 Nov 2012 22:47:06 GMT
Author: cutting
Date: Wed Nov 28 22:47:05 2012
New Revision: 1414979

URL: http://svn.apache.org/viewvc?rev=1414979&view=rev
Log:
AVRO-1177. Ruby: Fix RPC to only send handshake for first request over a connection.  Contributed
by Georg Franz.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/ruby/lib/avro/ipc.rb

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1414979&r1=1414978&r2=1414979&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Wed Nov 28 22:47:05 2012
@@ -66,6 +66,9 @@ Trunk (not yet released)
     AVRO-1206. Ruby: Fix UTF-8 handling in Ruby 1.9.
     (Nicolas Fouché via cutting)
 
+    AVRO-1177. Ruby: Fix RPC to only send handshake for first request
+    over a connection.  (Georg Franz via cutting)
+
 Avro 1.7.2 (20 October 2012)
 
   NEW FEATURES

Modified: avro/trunk/lang/ruby/lib/avro/ipc.rb
URL: http://svn.apache.org/viewvc/avro/trunk/lang/ruby/lib/avro/ipc.rb?rev=1414979&r1=1414978&r2=1414979&view=diff
==============================================================================
--- avro/trunk/lang/ruby/lib/avro/ipc.rb (original)
+++ avro/trunk/lang/ruby/lib/avro/ipc.rb Wed Nov 28 22:47:05 2012
@@ -242,7 +242,7 @@ module Avro::IPC
 
     # Called by a server to deserialize a request, compute and serialize
     # a response or error. Compare to 'handle()' in Thrift.
-    def respond(call_request)
+    def respond(call_request, transport=nil)
       buffer_decoder = Avro::IO::BinaryDecoder.new(StringIO.new(call_request))
       buffer_writer = StringIO.new('', 'w+')
       buffer_encoder = Avro::IO::BinaryEncoder.new(buffer_writer)
@@ -250,7 +250,7 @@ module Avro::IPC
       response_metadata = {}
 
       begin
-        remote_protocol = process_handshake(buffer_decoder, buffer_encoder)
+        remote_protocol = process_handshake(buffer_decoder, buffer_encoder, transport)
         # handshake failure
         unless remote_protocol
           return buffer_writer.string
@@ -302,7 +302,10 @@ module Avro::IPC
       buffer_writer.string
     end
 
-    def process_handshake(decoder, encoder)
+    def process_handshake(decoder, encoder, connection=nil)
+      if connection && connection.is_connected?
+        return connection.protocol
+      end
       handshake_request = HANDSHAKE_RESPONDER_READER.read(decoder)
       handshake_response = {}
 
@@ -338,6 +341,11 @@ module Avro::IPC
       end
 
       HANDSHAKE_RESPONDER_WRITER.write(handshake_response, encoder)
+
+      if connection && handshake_response['match'] != 'NONE'
+        connection.protocol = remote_protocol
+      end
+
       remote_protocol
     end
 
@@ -366,9 +374,15 @@ module Avro::IPC
     # A simple socket-based Transport implementation.
 
     attr_reader :sock, :remote_name
+    attr_accessor :protocol
 
     def initialize(sock)
       @sock = sock
+      @protocol = nil
+    end
+
+    def is_connected?()
+      !!@protocol
     end
 
     def transceive(request)



Mime
View raw message