I am attempting to stream a large JSON file ( ~300mb ) to Solr using JRuby ( 9.1.8.0 using jruby-openssl 0.9.21 ). The remote Solr server is using SSL authentication. I've included my script below.
When I use JRuby, I run out of heap space almost immediately using default 500mb. Using MRI, the usage never goes over 40mb. Not using SSL, JRuby works fine. I've done similar processes in pure Java, but never had these kinds of problems. Not sure what's happening here..
Thanks for any suggestions...
require 'openssl'
require 'net/http'
require 'json'
PEM_FILE = ENV["CLIENT_CERT"]
SOLR_URL = ENV["SOLR_URL"]
class SolrClient
DEFAULT_OPTIONS = {
use_ssl: true,
verify_mode: OpenSSL::SSL::VERIFY_PEER,
keep_alive_timeout: 30,
cert: OpenSSL::X509::Certificate.new(IO.read(PEM_FILE)),
key: OpenSSL::PKey::RSA.new(IO.read(PEM_FILE)),
}
def initialize(http = nil)
if http
@http = http
else
@http = Net::HTTP.start('my.solr.url', 443, DEFAULT_OPTIONS)
end
end
def update()
bytes = File.open('index_batch.json', 'rb').bytes.count.to_s
stream = File.open('index_batch.json', 'rb')
puts "starting request..."
request = Net::HTTP::Post.new "/solr/archivesspace/update"
request['Content-Type'] = 'application/json'
request['Content-Length'] = bytes
request.body_stream = stream
response = @http.request request
puts response.body
end
end
SolrClient.new.update