-
Notifications
You must be signed in to change notification settings - Fork 643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression: Http connect timeout no longer wired up #1384
Comments
Jena now uses Apache HttpClient is only in the dependencies because jsonld-java uses it. If Titanium becomes the only JSON-LD provider, then it won't be needed. We can probably drop the explicit mention now. jena used to need to control the version. In
In the case of HTTP/2 : there is no TCP connection setup other that the one shared host-host connection. HTTP/3 : different again. I assumed the lack of timeout controls for
|
Sigh, too many issues lately so I it happens I do things too hastily - I didn't notice that the stack overflow snippet referred to apache http client because the title referred to java http and I googled for java net http. I see, the method now is java.net.http.HttpClient.Builder.connectTimeout (javadoc) So I'll look into supplying my own HttpClient instance via |
Yes - setting up the HttpClient is the right way to do it. It is the only way as it get frozen at that point. It is possible to manually clone the setting of an HttpClient but it's afresh setup and not having the same connection caching (HTTP/1.1). |
Hm again a twist: So with the connect timeout no longer present on the connection itself I have to set it on initialization. However for this part I was using my own assembler-like setup which sets up a factory for RDFConnection objects from an RDF document. Back then I didn't realize that Jena's assembler system is generic so it can create any java object from RDF. In my case, this allows for linking RDF benchmark results back to the connection setup and the involved thresholds. Rather then extending my own system I'd rather integrate with Jena assemblers. So a rought draft would look like #conn.ttl
<#httpClient> a ja:HttpClient ;
ja:connectTimeout 10 . # seconds
<#conn> rdf:type ja:HttpRDFConnection;
ja:destination <http://dbpedia.org/sparql> ;
ja:httpClient <#httpClient> . Followed by Resource spec = ModelFactory.load("conn.ttl").getResource("#conn");
RDFConnection conn = RDFConnectionFactory.assemble(spec); However, instead of returning only a single connection it may be better to create a factory for connections: /** A factory/supplier of RDFConnection instances. Similar to a JDBC DataSource. */
public interface RDFDataSource
{
RDFConnection getConnection();
}
RDFDataSourceFactory.assemble(...); Would this be a reasonable approach? And would it make sense to add this functionality to Jena itself at some point? |
Reasonable yes. I use assembler to make things other than datasets quite often. https://github.com/Telicent-io/jena-fuseki-kafka/blob/main/ex-connector.ttl is a connector between Kafka and Jena.
There is no need to be in Jena, nor use Is it something general other users would want? From what you describe ( Aside: I've been toying with making more of assembling at the graph level. |
If this issue is finished, could you close it please? It is very helpful to wrap things up - it helps track the state of the project. We have the "discussions" area on GH for longer running and open ended discussions. "Issues" are ideally actionable. There will more of them so longer discussions that involve general users may can get a little lost if mixed into a big "issues" pool. |
Well it's the analogy to JDBC, where DataSource is the factory for connection instances. Also in the LSQ system, I use the RDF-variant of that interface for connection recovery: If it turns out that a connection was lost (e.g. due to a system-under-test actually crashing on a query) I can call In the bigger picture, Spring has the EmbeddedDatabase interface which extends DataSource with a So this pattern with an (RDF)DataSource is not my invention - but I noticed it's not part of the RDFConnection API. If you want more evidence I could also eventually write to the Jena dev mailing list about it.
Yes, sure, I don't mean to 'spam' Jena with my custom components. But I think an assembler for the already Jena native class RDFConnection+HttpClient (maybe later also RDFDataSource) would be nice. But for now I'll go ahead as you suggest with making the changes in my own code. I leave the issue open in case you want to leave a comment on the RDFDataSource, other than that you can close it. |
I confused by whether you are arguing for RDFDataSource or the assembler. If you are proposing RDFDataSource with all the sophistication you describe (caveat - inevitable overlaps with java.net.http.HttpClient), then great (at the RDFLink level). An assembler on its own seems isolated and can wait until RDFDataSource.
That's a good idea. And/or start a discussion. |
Version
4.6.0-SNAPSHOT
What happened?
When trying to re-activate one of my sparql benchmark processors (LSQ) I noticed that the following line no longer works with a remote HTTP connection:
Initial/connect timeout may be a bit of a niche feature but when working with third-party endpoints it can be a very handy thing - I once had a case where a downed sparql endpoint would hold the connection for several minutes; that's why eventually I made use of this Jena feature.
In my case, the line above ends up at QueryExecHTTPBuilder which raises a
UnsupportedOperationException
:Attempting to using the more recent
conn.newQuery().setTimeout()
API also does not work, because it lacks lacks a method to set the initial (aka connect) timeout alltogether.According to stack overflow the Java http client actually supports this feature so it seems it's just a matter of wiring this up again:
Which environment is running?
Relevant output and stacktrace
No response
Are you interested in making a pull request?
Yes
The text was updated successfully, but these errors were encountered: