public class RemoteRepositoryManager extends RemoteRepositoryBase implements AutoCloseable
Modifier and Type | Class and Description |
---|---|
static class |
RemoteRepositoryManager.ComputeMode |
Modifier and Type | Field and Description |
---|---|
protected Executor |
executor
Thread pool for processing HTTP responses in background.
|
protected org.eclipse.jetty.client.HttpClient |
httpClient
The client used for http connections.
|
protected boolean |
useLBS
When
true , the REST API methods will use the load balancer
aware requestURLs. |
BASE_URI, BD_NULL_GRAPH, BINDING_PREFIX, DEFAULT_GRAPH_URI, DEFAULT_MAX_REQUEST_URL_LENGTH, DEFAULT_NAMESPACE, DEFAULT_QUERY_METHOD, FORCE_INDEX_CREATE, HTTP_HEADER_BIGDATA_MAX_QUERY_MILLIS, INCLUDE_INFERRED, MAX_QUERY_TIME_MILLIS, MAX_REQUEST_URL_LENGTH, NAMED_GRAPH_URI, OPTION_CREATE_KB_NAMESPACE, QUERY_METHOD, QUERYID, USING_GRAPH_URI, USING_NAMED_GRAPH_URI, UTF8
Constructor and Description |
---|
RemoteRepositoryManager()
Create a manager that is not aware of a specific blazegraph backend.
|
RemoteRepositoryManager(String serviceURL)
Create a manager client for the specified serviceURL.
|
RemoteRepositoryManager(String serviceURL,
boolean useLBS)
Create a remote client for the specified serviceURL that optionally use
the load balanced URLs.
|
RemoteRepositoryManager(String serviceURL,
boolean useLBS,
org.eclipse.jetty.client.HttpClient httpClient,
Executor executor)
Create a remote client for the specified serviceURL (core impl).
|
RemoteRepositoryManager(String serviceURL,
org.eclipse.jetty.client.HttpClient httpClient,
Executor executor)
Create a remote client for the specified serviceURL.
|
Modifier and Type | Method and Description |
---|---|
boolean |
booleanResults(ConnectOptions opts,
UUID queryId,
IPreparedQueryListener listener)
Parse a SPARQL result set for an ASK query.
|
void |
cancel(UUID queryId)
Cancel a query running remotely on the server.
|
void |
close() |
void |
createRepository(String namespace,
Properties properties)
Create a new KB instance.
|
void |
createRepository(String namespace,
Properties properties,
UUID uuid)
Create a new KB instance.
|
void |
deleteRepository(String namespace)
Destroy a KB instance.
|
void |
deleteRepository(String namespace,
UUID uuid)
Destroy a KB instance.
|
JettyResponseListener |
doConnect(ConnectOptions opts)
Connect to a SPARQL end point (GET or POST query only).
|
void |
doDataLoader(Properties properties)
Initiate the data loader for a namespace within the a NSS
|
boolean |
dropNamespaceFromMapgraph(String namespace)
Drops the given namespace from the mapgraph runtime.
|
protected void |
finalize() |
String |
getBaseServiceURL()
The path to the root of the web application (without the trailing "/").
|
Executor |
getExecutor()
The executor for processing http and other client operations.
|
String |
getMapgraphStatus()
Returns the current status report for mapgraph.
|
int |
getMaxRequestURLLength()
Return the maximum requestURL length before the request is converted into
a POST using a
application/x-www-form-urlencoded request
entity. |
Properties |
getPreparedProperties(String namespace,
Properties properties)
Prepare configuration properties for a new KB instance.
|
Properties |
getPreparedProperties(String namespace,
Properties properties,
UUID uuid) |
String |
getQueryMethod()
Return the HTTP verb that will be used for a QUERY (versus an UPDATE or
other mutation operations) (default ).
|
protected String |
getRepositoryBaseURLForNamespace(String namespace)
Return the base URL for a remote repository (less the /sparql path
component).
|
org.openrdf.query.GraphQueryResult |
getRepositoryDescriptions()
Obtain a VoID description of
the configured KBs.
|
org.openrdf.query.GraphQueryResult |
getRepositoryDescriptions(UUID uuid)
Obtain a VoID description of
the configured KBs.
|
RemoteRepository |
getRepositoryForDefaultNamespace()
Obtain a flyweight
RemoteRepository for the default namespace
associated with the remote service. |
RemoteRepository |
getRepositoryForNamespace(String namespace)
Obtain a flyweight
RemoteRepository for a data set managed by the
remote service. |
RemoteRepository |
getRepositoryForURL(String sparqlEndpointURL)
Obtain a flyweight
RemoteRepository for the data set having the
specified SPARQL end point. |
RemoteRepository |
getRepositoryForURL(String sparqlEndpointURL,
IRemoteTx tx)
Obtain a flyweight
RemoteRepository for the data set having the
specified SPARQL end point. |
Properties |
getRepositoryProperties(String namespace)
Return the effective configuration properties for the named data set.
|
Properties |
getRepositoryProperties(String namespace,
UUID uuid) |
RemoteTransactionManager |
getTransactionManager()
Return the remote client for the transaction manager API.
|
boolean |
getUseLBS()
Return
true iff the REST API methods will use the load
balancer aware requestURLs. |
boolean |
mapgraphRuntimeAvailable()
Checks whether the mapgraph runtime is available.
|
boolean |
namespacePublishedToMapgraph(String namespace)
Checks whether the given namespace has been published.
|
protected ConnectOptions |
newQueryConnectOptions(String sparqlEndpointURL,
UUID uuid,
IRemoteTx tx)
Return the
ConnectOptions which will be used by default for the
SPARQL end point for a QUERY or other idempotent operation. |
org.eclipse.jetty.client.api.Request |
newRequest(String uri,
String method) |
protected ConnectOptions |
newUpdateConnectOptions(String sparqlEndpointURL,
UUID uuid,
IRemoteTx tx)
Return the
ConnectOptions which will be used by default for the
SPARQL end point for an UPDATE or other non-idempotant operation. |
void |
onlineBackup(String file,
boolean compress,
boolean block)
Initiate an online backup using the
BackupServlet . |
boolean |
publishNamespaceToMapgraph(String namespace)
Publishes the given namespace to the mapgraph runtime.
|
void |
rebuildTextIndex(String namespace,
boolean forceBuildTextIndex) |
void |
rebuildTextIndex(String namespace,
boolean forceBuildTextIndex,
UUID uuid) |
void |
resetMapgraphRuntime(RemoteRepositoryManager.ComputeMode computeMode)
Resets the mapgraph runtime for the compute mode.
|
void |
setMaxRequestURLLength(int newVal) |
void |
setQueryMethod(String method)
Set the default HTTP verb for QUERY and other idempotant operations.
|
Collection<RunningQuery> |
showQueries()
List the currently running queries on the server
|
String |
toString() |
org.openrdf.query.TupleQueryResult |
tupleResults(ConnectOptions opts,
UUID queryId,
IPreparedQueryListener listener)
Extracts the solutions from a SPARQL query.
|
asGraph, booleanResults, checkResponseCode, contextsResults, getContextPath, mutationResults, rangeCountResults, serialize, toStrings
protected final boolean useLBS
true
, the REST API methods will use the load balancer
aware requestURLs. The load balancer has essentially zero cost when not
using HA, so it is recommended to always specify true
. When
false
, the REST API methods will NOT use the load balancer
aware requestURLs.protected final org.eclipse.jetty.client.HttpClient httpClient
protected final Executor executor
public RemoteRepositoryManager()
new RemoteRepositoryManager().getRepositoryForURL(sparqlEndpointURL)The same pattern MAY be used to perform SPARQL QUERY or SPARQL UPDATE operations against non-blazegraph sparql end points.
public RemoteRepositoryManager(String serviceURL)
http://host:port/bigdataThe serviceURL can be used to obtain sparql end point URLs for:
serviceURL
- The path to the root of the web application (without the
trailing "/"). /sparql
will be appended to this
path to obtain the SPARQL end point for the default data set.public RemoteRepositoryManager(String serviceURL, boolean useLBS)
serviceURL
- The path to the root of the web application (without the
trailing "/"). /sparql
will be appended to this
path to obtain the SPARQL end point for the default data set.useLBS
- When true
, the REST API methods will use the load
balancer aware requestURLs. The load balancer has essentially
zero cost when not using HA, so it is recommended to always
specify true
. When false
, the REST
API methods will NOT use the load balancer aware requestURLs.public RemoteRepositoryManager(String serviceURL, org.eclipse.jetty.client.HttpClient httpClient, Executor executor)
serviceURL
- The path to the root of the web application (without the
trailing "/"). /sparql
will be appended to this
path to obtain the SPARQL end point for the default data set.httpClient
- The client is managed externally and, in particular,
may be shared, so we don't close it in close()
.
When not present (null), an HttpClient
will be
allocated and scoped to this
RemoteRepositoryManager
instance, and closed
in close()
.executor
- An executor used to service http client requests. (optional).
When not present, an Executor
will be allocated and
scoped to this RemoteRepositoryManager
instance.
TODO Should this be deprecated since it does not force the
caller to choose a value for useLBS
?
This version does not force the caller to decide whether or not the LBS pattern will be used. In general, it should be used if the end point is bigdata. This class is generally, but not always, used with a bigdata end point. The main exception is SPARQL Basic Federated Query. For that use case we can not assume that the end point is bigdata and thus we can not use the LBS prefix.
public RemoteRepositoryManager(String serviceURL, boolean useLBS, org.eclipse.jetty.client.HttpClient httpClient, Executor executor)
serviceURL
- The path to the root of the web application (without the
trailing "/"). /sparql
will be appended to this
path to obtain the SPARQL end point for the default data set.useLBS
- When true
, the REST API methods will use the load
balancer aware requestURLs. The load balancer has essentially
zero cost when not using HA, so it is recommended to always
specify true
. When false
, the REST
API methods will NOT use the load balancer aware requestURLs.httpClient
- The client is managed externally and, in particular,
may be shared, so we don't close it in close()
.
When not present (null), an HttpClient
will be
allocated and scoped to this
RemoteRepositoryManager
instance, and closed
in close()
.executor
- An executor used to service http client requests. (optional).
When not present, an Executor
will be allocated and
scoped to this RemoteRepositoryManager
instance.public RemoteTransactionManager getTransactionManager()
public Executor getExecutor()
public String getBaseServiceURL()
Note: This SHOULD NOT be the SPARQL end point URL. The NanoSparqlServer
has a wider interface. This should be the base URL of that interface. The
SPARQL end point URL for the default data set is formed by appending
/sparql
.
public boolean getUseLBS()
true
iff the REST API methods will use the load
balancer aware requestURLs. The load balancer has essentially zero cost
when not using HA, so it is recommended to always specify
true
. When false
, the REST API methods will NOT
use the load balancer aware requestURLs.public int getMaxRequestURLLength()
application/x-www-form-urlencoded
request
entity.public void setMaxRequestURLLength(int newVal)
public String getQueryMethod()
setQueryMethod(String)
public void setQueryMethod(String method)
method
- The method which may be "POST" or "GET".getQueryMethod()
protected void finalize() throws Throwable
Ensure resource is closed.
finalize
in class Object
Throwable
AutoCloseable
,
Memory leak in
CI? public void close() throws Exception
close
in interface AutoCloseable
Exception
protected String getRepositoryBaseURLForNamespace(String namespace)
namespace
- The namespace.public RemoteRepository getRepositoryForDefaultNamespace()
RemoteRepository
for the default namespace
associated with the remote service.public RemoteRepository getRepositoryForNamespace(String namespace)
RemoteRepository
for a data set managed by the
remote service.namespace
- The name of the data set (its bigdata namespace).public RemoteRepository getRepositoryForURL(String sparqlEndpointURL)
RemoteRepository
for the data set having the
specified SPARQL end point. The load balancer will be used or not as per
the parameters to the RemoteRepositoryManager
constructor.sparqlEndpointURL
- The URL of the SPARQL end point.public RemoteRepository getRepositoryForURL(String sparqlEndpointURL, IRemoteTx tx)
RemoteRepository
for the data set having the
specified SPARQL end point. The load balancer will be used or not as per
the parameters to the RemoteRepositoryManager
constructor.sparqlEndpointURL
- The URL of the SPARQL end point.timestamp
- The timestamp that will be added to all requests for the
sparqlEndPoint (optional).public org.openrdf.query.GraphQueryResult getRepositoryDescriptions() throws Exception
Note: This method uses an HTTP GET and hence can be cached by the server.
public org.openrdf.query.GraphQueryResult getRepositoryDescriptions(UUID uuid) throws Exception
Note: This method uses an HTTP GET and hence can be cached by the server.
public void createRepository(String namespace, Properties properties) throws Exception
namespace
- The namespace of the KB instance.properties
- The configuration properties for that KB instance.Exception
public void createRepository(String namespace, Properties properties, UUID uuid) throws Exception
namespace
- The namespace of the KB instance.properties
- The configuration properties for that KB instance.uuid
- The UUID
to be associated with this request.Exception
public Properties getPreparedProperties(String namespace, Properties properties) throws Exception
namespace
- The namespace of the KB instance.properties
- The configuration properties for that KB instance.Exception
public Properties getPreparedProperties(String namespace, Properties properties, UUID uuid) throws Exception
Exception
public void rebuildTextIndex(String namespace, boolean forceBuildTextIndex) throws Exception
-
- Exception
public void rebuildTextIndex(String namespace, boolean forceBuildTextIndex, UUID uuid) throws Exception
Exception
public void deleteRepository(String namespace) throws Exception
namespace
- The namespace of the KB instance.Exception
public void deleteRepository(String namespace, UUID uuid) throws Exception
public boolean publishNamespaceToMapgraph(String namespace) throws Exception
NoGPUAccelerationAvailableException
Exception
public boolean dropNamespaceFromMapgraph(String namespace) throws Exception
NoGPUAccelerationAvailableException
Exception
public boolean namespacePublishedToMapgraph(String namespace) throws Exception
NoGPUAccelerationAvailableException
Exception
public void resetMapgraphRuntime(RemoteRepositoryManager.ComputeMode computeMode) throws Exception
computeMode
- the desired compute modeException
public String getMapgraphStatus() throws Exception
Exception
public boolean mapgraphRuntimeAvailable() throws Exception
Exception
public Properties getRepositoryProperties(String namespace) throws Exception
Note: While it is possible to change some configuration options are a data set has been created, many aspects of a "data set" configuration are "baked in" when the data set is created and can not be changed. For this reason, no general purpose mechanism is being offered to change the properties for a configured data set instance.
namespace
- The name of the data set.Exception
public Properties getRepositoryProperties(String namespace, UUID uuid) throws Exception
Exception
public void onlineBackup(String file, boolean compress, boolean block) throws Exception
BackupServlet
.file
- -- The name of the file for the backup. (default = "backup.jnl")compress
- -- Use compression for the snapshot (default = false)block
- -- Block on the response (default = true)Exception
https://jira.blazegraph.com/browse/BLZG-1727
public void doDataLoader(Properties properties) throws Exception
properties
- The properties for the DataLoader ServletException
BLZG-1713
public JettyResponseListener doConnect(ConnectOptions opts) throws Exception
opts
- The connection options.Exception
protected final ConnectOptions newQueryConnectOptions(String sparqlEndpointURL, UUID uuid, IRemoteTx tx)
ConnectOptions
which will be used by default for the
SPARQL end point for a QUERY or other idempotent operation.sparqlEndpointURL
- The SPARQL end point.uuid
- The unique identifier for the request that may be used to
CANCEL the request.tx
- A transaction that will isolate the operation (optional).protected final ConnectOptions newUpdateConnectOptions(String sparqlEndpointURL, UUID uuid, IRemoteTx tx)
ConnectOptions
which will be used by default for the
SPARQL end point for an UPDATE or other non-idempotant operation.sparqlEndpointURL
- The SPARQL end point.uuid
- The unique identifier for the request that may be used to
CANCEL the request.tx
- A transaction that will isolate the operation (optional).public void cancel(UUID queryId) throws Exception
queryID
- the UUID of the query to cancelException
public Collection<RunningQuery> showQueries() throws Exception
Exception
public org.openrdf.query.TupleQueryResult tupleResults(ConnectOptions opts, UUID queryId, IPreparedQueryListener listener) throws Exception
response
- The connection from which to read the results.listener
- The listener to notify when the query result has been closed
(optional).Exception
- If anything goes wrong.public boolean booleanResults(ConnectOptions opts, UUID queryId, IPreparedQueryListener listener) throws Exception
response
- The connection from which to read the results.true
or false
depending on what was
encoded in the SPARQL result set.Exception
- If anything goes wrong, including if the result set does not
encode a single boolean value.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.