| 
														
															@@ -10,21 +10,22 @@ module Blazer 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         header = {"Content-Type" => "application/json", "Accept" => "application/json"} 
														 | 
														
														 | 
														
															         header = {"Content-Type" => "application/json", "Accept" => "application/json"} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         context = {} 
														 | 
														
														 | 
														
															         context = {} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        if data_source.timeout 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-          context = data_source.timeout.to_i * 1000 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        end 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        timeout = data_source.timeout ? data_source.timeout.to_i : 300 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         data = { 
														 | 
														
														 | 
														
															         data = { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           query: statement, 
														 | 
														
														 | 
														
															           query: statement, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-          context: context 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          context: { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            timeout: timeout 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+          } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         uri = URI.parse("#{settings["url"]}/druid/v2/sql/") 
														 | 
														
														 | 
														
															         uri = URI.parse("#{settings["url"]}/druid/v2/sql/") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         http = Net::HTTP.new(uri.host, uri.port) 
														 | 
														
														 | 
														
															         http = Net::HTTP.new(uri.host, uri.port) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        http.read_timeout = timeout 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         begin 
														 | 
														
														 | 
														
															         begin 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           response = JSON.parse(http.post(uri.request_uri, data.to_json, header).body) 
														 | 
														
														 | 
														
															           response = JSON.parse(http.post(uri.request_uri, data.to_json, header).body) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           if response.is_a?(Hash) 
														 | 
														
														 | 
														
															           if response.is_a?(Hash) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            error = response["errorMessage"] 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            error = response["errorMessage"] || "Unknown error: #{response.inspect}" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             if error.include?("timed out") 
														 | 
														
														 | 
														
															             if error.include?("timed out") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															               error = Blazer::TIMEOUT_MESSAGE 
														 | 
														
														 | 
														
															               error = Blazer::TIMEOUT_MESSAGE 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             end 
														 | 
														
														 | 
														
															             end 
														 |