Package org.aksw.iguana.cc.utils.http
Class RequestFactory
java.lang.Object
org.aksw.iguana.cc.utils.http.RequestFactory
A factory for creating HTTP requests.
The factory can create requests for different types of HTTP methods and different types of SPARQL queries.
The factory can also cache requests to avoid creating the same request multiple times.
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionRequestFactory
(SPARQLProtocolWorker.Config workerConfig) Creates a new request factory for the given worker configuration. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.hc.core5.http.nio.AsyncRequestProducer
buildHttpRequest
(QueryHandler.QueryStreamWrapper queryHandle) Builds an HTTP request for a given query.void
preloadRequests
(QueryHandler queryHandler) Builds every request once, so that the requests can be loaded into the cache, if the queries themselves are cached.
-
Constructor Details
-
RequestFactory
Creates a new request factory for the given worker configuration.- Parameters:
workerConfig
- the worker configuration
-
-
Method Details
-
buildHttpRequest
public org.apache.hc.core5.http.nio.AsyncRequestProducer buildHttpRequest(QueryHandler.QueryStreamWrapper queryHandle) throws IOException, URISyntaxException Builds an HTTP request for a given query. The request is built according to the request type and the query type that was set in the constructor. If the query is cached, the cached data will be used to build the request. Cached requests will also be sent non-chunked. If the query has not been cached by the query handler, the entity producer will use the query stream supplier to send the query in chunks. All Requests will also be cached, and they will not be rebuilt if they are requested again.- Parameters:
queryHandle
- the query handle to build the request for- Returns:
- the request as an AsyncRequestProducer
- Throws:
URISyntaxException
- if the URI is invalidIOException
- if the query stream cannot be read
-
preloadRequests
Builds every request once, so that the requests can be loaded into the cache, if the queries themselves are cached. This is done to avoid the overhead of building (url-encoding) the requests during the benchmark.- Parameters:
queryHandler
- the query handler to preload requests for
-