Skip to content

Commit

Permalink
merge with upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Dec 10, 2021
2 parents ba3edcd + d26b364 commit 4523fd3
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 22 deletions.
54 changes: 36 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/ncbo/sparql-client.git
revision: 87bc0e8976519cdcdef06169556677467a10fcfc
revision: fb4a89b420f8eb6dda5190a126b6c62e32c4c0c9
branch: master
specs:
sparql-client (1.0.1)
Expand Down Expand Up @@ -34,36 +34,52 @@ GEM
addressable (2.3.5)
builder (3.2.4)
coderay (1.1.3)
concurrent-ruby (1.1.7)
concurrent-ruby (1.1.9)
cube-ruby (0.0.3)
daemons (1.3.1)
docile (1.3.2)
daemons (1.4.1)
docile (1.4.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
eventmachine (1.2.7)
faraday (1.1.0)
faraday (1.8.0)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0.1)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.1)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
multipart-post (>= 1.2, < 3)
ruby2_keywords
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
http-accept (1.7.0)
http-cookie (1.0.3)
http-cookie (1.0.4)
domain_name (~> 0.5)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
json_pure (2.3.1)
json_pure (2.6.1)
macaddr (1.7.2)
systemu (~> 2.6.5)
method_source (1.0.0)
mime-types (3.3.1)
mime-types (3.4.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2020.0512)
mime-types-data (3.2021.1115)
minitest (4.7.5)
multi_json (1.15.0)
multipart-post (2.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
net-http-persistent (2.9.4)
netrc (0.11.0)
pry (0.13.1)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
rack (2.2.3)
Expand All @@ -73,10 +89,10 @@ GEM
activesupport (>= 2.3)
rack-protection (2.1.0)
rack
rake (13.0.1)
rake (13.0.6)
rdf (1.0.8)
addressable (>= 2.2)
redis (4.2.2)
redis (4.5.1)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
Expand All @@ -85,27 +101,29 @@ GEM
rsolr (2.3.0)
builder (>= 2.1.2)
faraday (>= 0.9.0)
ruby2_keywords (0.0.2)
simplecov (0.19.1)
ruby2_keywords (0.0.5)
simplecov (0.21.2)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.3)
sinatra (2.1.0)
mustermann (~> 1.0)
rack (~> 2.2)
rack-protection (= 2.1.0)
tilt (~> 2.0)
systemu (2.6.5)
thin (1.7.2)
thin (1.8.1)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
thread_safe (0.3.6)
tilt (2.0.10)
tzinfo (0.3.57)
tzinfo (0.3.60)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.7)
unf_ext (0.0.8)
uuid (2.3.9)
macaddr (~> 1.0)

Expand Down
29 changes: 25 additions & 4 deletions lib/goo/sparql/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,19 @@ class Client < RSPARQL::Client
def status_based_sleep_time(operation)
sleep(0.5)
st = self.status

if st[:exception]
raise Exception, st[:exception]
end

if st[:outstanding] > 50
raise Exception, "Too many outstanding queries. We cannot write to the backend"
end

if st[:outstanding] > 0
return 2.5
end

if st[:running] < 4
return 0.8
end
Expand Down Expand Up @@ -88,6 +95,7 @@ def append_triples_no_bnodes(graph,file_path,mime_type_in)
mime_type = "text/x-nquads"
graph = "http://data.bogus.graph/uri"
end

data_file = File.read(bnodes_filter)
params = {method: :post, url: "#{url.to_s}", headers: {"content-type" => mime_type, "mime-type" => mime_type}, timeout: nil}
backend_name = Goo.sparql_backend_name
Expand Down Expand Up @@ -167,13 +175,26 @@ def extract_number_from(i,text)
end

def status
resp = { running: -1, outstanding: -1, exception: nil }
status_url = (url.to_s.split("/")[0..-2].join "/") + "/status/"
resp_text = Net::HTTP.get(URI(status_url))
running = extract_number_from(230,resp_text)
resp_text = nil

begin
resp_text = Net::HTTP.get(URI(status_url))
rescue StandardError => e
resp[:exception] = "Error connecting to triple store: #{e.class}: #{e.message}\n#{e.backtrace.join("\n\t")}"
return resp
end

run_text = "Running queries</th><td>"
i_run = resp_text.index(run_text) + run_text.length
running = extract_number_from(i_run, resp_text)
out_text = "Outstanding queries</th><td>"
i_out = resp_text.index(out_text) + out_text.length
outstanding = extract_number_from(i_out,resp_text)
return { running: running, outstanding: outstanding }
outstanding = extract_number_from(i_out, resp_text)
resp[:running] = running
resp[:outstanding] = outstanding
resp
end
end
end
Expand Down

0 comments on commit 4523fd3

Please sign in to comment.