From bad5823a02cf873f5c9e01c091022b173745a55b Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Tue, 1 Mar 2022 10:35:16 +0100 Subject: [PATCH 1/5] add configuration variable for setting owlapi_wrapper java heap size --- lib/ontologies_linked_data/config/config.rb | 64 +++++++++++---------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/lib/ontologies_linked_data/config/config.rb b/lib/ontologies_linked_data/config/config.rb index b5aaadf2..c30c70d2 100644 --- a/lib/ontologies_linked_data/config/config.rb +++ b/lib/ontologies_linked_data/config/config.rb @@ -15,19 +15,21 @@ def config(&block) overide_connect_goo = false # Set defaults - @settings.goo_backend_name ||= "4store" + @settings.goo_backend_name ||= '4store' @settings.goo_port ||= 9000 - @settings.goo_host ||= "localhost" - @settings.goo_path_query ||= "/sparql/" - @settings.goo_path_data ||= "/data/" - @settings.goo_path_update ||= "/update/" - @settings.search_server_url ||= "http://localhost:8983/solr/term_search_core1" - @settings.property_search_server_url ||= "http://localhost:8983/solr/prop_search_core1" - @settings.repository_folder ||= "./test/data/ontology_files/repo" - @settings.rest_url_prefix ||= "http://data.bioontology.org/" + @settings.goo_host ||= 'localhost' + @settings.goo_path_query ||= '/sparql/' + @settings.goo_path_data ||= '/data/' + @settings.goo_path_update ||= '/update/' + @settings.search_server_url ||= 'http://localhost:8983/solr/term_search_core1' + @settings.property_search_server_url ||= 'http://localhost:8983/solr/prop_search_core1' + @settings.repository_folder ||= './test/data/ontology_files/repo' + @settings.rest_url_prefix ||= 'http://data.bioontology.org/' @settings.enable_security ||= false @settings.enable_slices ||= false + # Java/JVM options + @settings.java_max_heap_size ||= '10240M' ### these params should be not ussed any more # removed so that dependencies shout # @@ -35,47 +37,47 @@ def config(&block) # @settings.redis_port ||= 6379 # ### - @settings.ui_host ||= "bioportal.bioontology.org" + @settings.ui_host ||= 'bioportal.bioontology.org' @settings.replace_url_prefix ||= false - @settings.id_url_prefix ||= "http://data.bioontology.org/" + @settings.id_url_prefix ||= 'http://data.bioontology.org/' @settings.queries_debug ||= false @settings.enable_monitoring ||= false - @settings.cube_host ||= "localhost" + @settings.cube_host ||= 'localhost' @settings.cube_port ||= 1180 # Caching http @settings.enable_http_cache ||= false - @settings.http_redis_host ||= "localhost" + @settings.http_redis_host ||= 'localhost' @settings.http_redis_port ||= 6379 #Caching goo - @settings.goo_redis_host ||= "localhost" + @settings.goo_redis_host ||= 'localhost' @settings.goo_redis_port ||= 6379 #Ontology Analytics Redis - @settings.ontology_analytics_redis_host ||= "localhost" + @settings.ontology_analytics_redis_host ||= 'localhost' @settings.ontology_analytics_redis_port ||= 6379 # PURL server config parameters @settings.enable_purl ||= false - @settings.purl_host ||= "purl.bioontology.org" + @settings.purl_host ||= 'purl.bioontology.org' @settings.purl_port ||= 80 - @settings.purl_username ||= "" - @settings.purl_password ||= "" - @settings.purl_maintainers ||= "" - @settings.purl_target_url_prefix ||= "http://bioportal.bioontology.org" + @settings.purl_username ||= '' + @settings.purl_password ||= '' + @settings.purl_maintainers ||= '' + @settings.purl_target_url_prefix ||= 'http://bioportal.bioontology.org' # Email settings @settings.enable_notifications ||= false - @settings.email_sender ||= "admin@example.org" # Default sender for emails - @settings.email_override ||= "test.email@example.org" # By default, all email gets sent here. Disable with email_override_disable. + @settings.email_sender ||= 'admin@example.org' # Default sender for emails + @settings.email_override ||= 'test.email@example.org' # By default, all email gets sent here. Disable with email_override_disable. @settings.email_disable_override ||= false - @settings.smtp_host ||= "localhost" + @settings.smtp_host ||= 'localhost' @settings.smtp_port ||= 25 - @settings.smtp_user ||= "user" - @settings.smtp_password ||= "password" + @settings.smtp_user ||= 'user' + @settings.smtp_password ||= 'password' @settings.smtp_auth_type ||= :none # :none, :plain, :login, :cram_md5 - @settings.smtp_domain ||= "localhost.localhost" + @settings.smtp_domain ||= 'localhost.localhost' @settings.enable_starttls_auto ||= false # set to true for use with gmail # number of times to retry a query when empty records are returned @@ -89,19 +91,19 @@ def config(&block) unless @settings.redis_host.nil? puts "Error: 'redis_host' is not a valid conf parameter." - puts " Redis databases were split into multiple hosts (09/22/13)." - raise Exception, "redis_host is not a valid conf parameter." + puts ' Redis databases were split into multiple hosts (09/22/13).' + raise Exception, 'redis_host is not a valid conf parameter.' end # Check to make sure url prefix has trailing slash - @settings.rest_url_prefix = @settings.rest_url_prefix + "/" unless @settings.rest_url_prefix[-1].eql?("/") + @settings.rest_url_prefix = @settings.rest_url_prefix + '/' unless @settings.rest_url_prefix[-1].eql?('/') puts "(LD) >> Using rdf store #{@settings.goo_host}:#{@settings.goo_port}" puts "(LD) >> Using term search server at #{@settings.search_server_url}" puts "(LD) >> Using property search server at #{@settings.property_search_server_url}" - puts "(LD) >> Using HTTP Redis instance at "+ + puts '(LD) >> Using HTTP Redis instance at '+ "#{@settings.http_redis_host}:#{@settings.http_redis_port}" - puts "(LD) >> Using Goo Redis instance at "+ + puts '(LD) >> Using Goo Redis instance at '+ "#{@settings.goo_redis_host}:#{@settings.goo_redis_port}" connect_goo unless overide_connect_goo From 623a7aa5a50bf51bbac561d332d4879bc70b2b9b Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Tue, 1 Mar 2022 10:42:16 +0100 Subject: [PATCH 2/5] update config simple to add java_max_heap_size configuration variable --- config/config.rb.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.rb.sample b/config/config.rb.sample index d102c892..9f1d6b1c 100644 --- a/config/config.rb.sample +++ b/config/config.rb.sample @@ -6,7 +6,7 @@ LinkedData.config do |config| config.repository_folder = "./test/data/ontology_files/repo" config.rest_url_prefix = "http://data.bioontology.org/" config.enable_security = false - + config.java_max_heap_size = '10240M' #PURL server config parameters config.enable_purl = false config.purl_host = "purl.bioontology.org" From bc13c871ddd49e56543e065e89dc26b7dec8036c Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Tue, 1 Mar 2022 10:43:34 +0100 Subject: [PATCH 3/5] update bubastis_diff to use the java_max_heap_size config variable --- lib/ontologies_linked_data/diff/bubastis_diff.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ontologies_linked_data/diff/bubastis_diff.rb b/lib/ontologies_linked_data/diff/bubastis_diff.rb index d5de6f65..55c37dd1 100644 --- a/lib/ontologies_linked_data/diff/bubastis_diff.rb +++ b/lib/ontologies_linked_data/diff/bubastis_diff.rb @@ -83,7 +83,7 @@ def call_bubastis_java_cmd end errors_log = File.join([@output_repo, "bubastis_diff_errors.log"]) File.delete errors_log if File.exist? errors_log - java_cmd = "java -DentityExpansionLimit=1500000 -Xmx5120M -jar #{@bubastis_jar_path} #{options.join(' ')}" + java_cmd = "java -DentityExpansionLimit=1500000 -Xmx#{LinkedData.settings.java_max_heap_size} -jar #{@bubastis_jar_path} #{options.join(' ')}" Diff.logger.info("Java call [#{java_cmd}]") stdout,stderr,status = Open3.capture3(java_cmd) if not status.success? From a6653a7356ce99c4d6189f635ee63e6ab1b7f1e6 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Tue, 1 Mar 2022 10:43:45 +0100 Subject: [PATCH 4/5] update owlapi to use the java_max_heap_size config variable --- lib/ontologies_linked_data/parser/owlapi.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ontologies_linked_data/parser/owlapi.rb b/lib/ontologies_linked_data/parser/owlapi.rb index f4fcb72b..35a3596e 100644 --- a/lib/ontologies_linked_data/parser/owlapi.rb +++ b/lib/ontologies_linked_data/parser/owlapi.rb @@ -71,7 +71,7 @@ def call_owlapi_java_command if File.exist? errors_log File.delete errors_log end - command_call = "java -DentityExpansionLimit=2500000 -Xmx10240M -jar #{@owlapi_wrapper_jar_path} #{options}" + command_call = "java -DentityExpansionLimit=2500000 -Xmx#{LinkedData.settings.java_max_heap_size} -jar #{@owlapi_wrapper_jar_path} #{options}" @logger.info("Java call [#{command_call}]") Open3.popen3(command_call) do |i,o,e,w| i.close From 0568286f4ee7e14c971261494d0c2bfad7436c74 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Tue, 1 Mar 2022 14:04:05 +0100 Subject: [PATCH 5/5] refactor code to use an instance variable --- lib/ontologies_linked_data/diff/bubastis_diff.rb | 3 ++- lib/ontologies_linked_data/parser/owlapi.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ontologies_linked_data/diff/bubastis_diff.rb b/lib/ontologies_linked_data/diff/bubastis_diff.rb index 55c37dd1..78f19fbe 100644 --- a/lib/ontologies_linked_data/diff/bubastis_diff.rb +++ b/lib/ontologies_linked_data/diff/bubastis_diff.rb @@ -43,6 +43,7 @@ def initialize(input_fileOld, input_fileNew) @input_fileNew = input_fileNew @output_repo = File.expand_path(@input_fileNew).gsub(File.basename(@input_fileNew),'') @file_diff_path = nil + @java_heap_size = LinkedData.settings.java_max_heap_size end def setup_environment @@ -83,7 +84,7 @@ def call_bubastis_java_cmd end errors_log = File.join([@output_repo, "bubastis_diff_errors.log"]) File.delete errors_log if File.exist? errors_log - java_cmd = "java -DentityExpansionLimit=1500000 -Xmx#{LinkedData.settings.java_max_heap_size} -jar #{@bubastis_jar_path} #{options.join(' ')}" + java_cmd = "java -DentityExpansionLimit=1500000 -Xmx#{@java_heap_size} -jar #{@bubastis_jar_path} #{options.join(' ')}" Diff.logger.info("Java call [#{java_cmd}]") stdout,stderr,status = Open3.capture3(java_cmd) if not status.success? diff --git a/lib/ontologies_linked_data/parser/owlapi.rb b/lib/ontologies_linked_data/parser/owlapi.rb index 35a3596e..a8402d12 100644 --- a/lib/ontologies_linked_data/parser/owlapi.rb +++ b/lib/ontologies_linked_data/parser/owlapi.rb @@ -21,6 +21,7 @@ def initialize(input_file, output_repo, opts = {}) @file_triples_path = nil @missing_imports = nil @reasoning = true + @java_heap_size = LinkedData.settings.java_max_heap_size end def setup_environment @@ -71,7 +72,7 @@ def call_owlapi_java_command if File.exist? errors_log File.delete errors_log end - command_call = "java -DentityExpansionLimit=2500000 -Xmx#{LinkedData.settings.java_max_heap_size} -jar #{@owlapi_wrapper_jar_path} #{options}" + command_call = "java -DentityExpansionLimit=2500000 -Xmx#{@java_heap_size} -jar #{@owlapi_wrapper_jar_path} #{options}" @logger.info("Java call [#{command_call}]") Open3.popen3(command_call) do |i,o,e,w| i.close