Package org.hobbit.storage.client
Class StorageServiceClient
java.lang.Object
org.hobbit.storage.client.StorageServiceClient
- All Implemented Interfaces:
Closeable,AutoCloseable
Simple client of the storage service implementing a synchronized
communication.
- Author:
- Michael Röder (roeder@informatik.uni-leipzig.de)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final longThe default maximum amount of time in millisecond the client is waiting for a response = 60000Lms.private static final org.slf4j.Loggerprivate RabbitRpcClientRPC client that is used for the communication. -
Constructor Summary
ConstructorsConstructorDescriptionStorageServiceClient(RabbitRpcClient rpcClient) Constructor creating a StorageServiceClient using the givenRabbitRpcClient. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static StorageServiceClientcreate(com.rabbitmq.client.Connection connection) Creates a StorageServiceClient using the given RabbitMQConnection.booleansendAskQuery(String query) Sends the given ASK query to the storage service and returns a boolean value or throws an Exception if an error occurs, the service needs too much time to respond or the response couldn't be parsed.org.apache.jena.rdf.model.ModelsendConstructQuery(String query) Sends the given CONSTRUCT query to the storage service and returns aModelvalue ornullif an error occurs, the service needs too much time to respond or the response couldn't be parsed.org.apache.jena.rdf.model.ModelsendDescribeQuery(String query) Sends the given DESCRIBE query to the storage service and returns aModelvalue ornullif an error occurs, the service needs too much time to respond or the response couldn't be parsed.booleansendInsertQuery(org.apache.jena.rdf.model.Model model, String graphURI) Inserts the given model into the storage and returnstrueif the query is successful orfalseif an error occurs or the service needs too much time to respond.private byte[]sendRequest(String request) Sends a request using rpcClient.org.apache.jena.query.ResultSetsendSelectQuery(String query) Sends the given SELECT query to the storage service and returns aResultSetvalue ornullif an error occurs, the service needs too much time to respond or the response couldn't be parsed.booleansendUpdateQuery(String query) Sends the given UPDATE query to the storage service and returnstrueif the query is successful orfalseif an error occurs or the service needs too much time to respond.voidsetMaxWaitingTime(long maxWaitingTime) Sets the maximum amount of time the client is waiting for a response.
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
DEFAULT_MAX_WAITING_TIME
private static final long DEFAULT_MAX_WAITING_TIMEThe default maximum amount of time in millisecond the client is waiting for a response = 60000Lms.- See Also:
-
rpcClient
RPC client that is used for the communication.
-
-
Constructor Details
-
StorageServiceClient
Constructor creating a StorageServiceClient using the givenRabbitRpcClient.- Parameters:
rpcClient- RPC client that is used for the communication
-
-
Method Details
-
create
public static StorageServiceClient create(com.rabbitmq.client.Connection connection) throws IOException Creates a StorageServiceClient using the given RabbitMQConnection.- Parameters:
connection- RabbitMQ connection used for the communication- Returns:
- a StorageServiceClient instance
- Throws:
IOException- if a problem occurs during the creation of the queues or the consumer.
-
setMaxWaitingTime
public void setMaxWaitingTime(long maxWaitingTime) Sets the maximum amount of time the client is waiting for a response.- Parameters:
maxWaitingTime- the maximum waiting time in milliseconds
-
sendRequest
Sends a request using rpcClient. If environment vars AES_PASSWORD and AES_SALT are set, the request will be encrypted. -
sendAskQuery
Sends the given ASK query to the storage service and returns a boolean value or throws an Exception if an error occurs, the service needs too much time to respond or the response couldn't be parsed.- Parameters:
query- ASK query- Returns:
- result for the query or
falseif an error occurs - Throws:
Exception- if no response has been received or the response couldn't be parsed.
-
sendConstructQuery
Sends the given CONSTRUCT query to the storage service and returns aModelvalue ornullif an error occurs, the service needs too much time to respond or the response couldn't be parsed.- Parameters:
query- CONSTRUCT query- Returns:
- result for the query or
null
-
sendDescribeQuery
Sends the given DESCRIBE query to the storage service and returns aModelvalue ornullif an error occurs, the service needs too much time to respond or the response couldn't be parsed.- Parameters:
query- DESCRIBE query- Returns:
- result for the query or
null
-
sendSelectQuery
Sends the given SELECT query to the storage service and returns aResultSetvalue ornullif an error occurs, the service needs too much time to respond or the response couldn't be parsed.- Parameters:
query- SELECT query- Returns:
- result for the query or
null
-
sendUpdateQuery
Sends the given UPDATE query to the storage service and returnstrueif the query is successful orfalseif an error occurs or the service needs too much time to respond.- Parameters:
query- UPDATE query- Returns:
- flag indicating whether the query has been executed successfully or not
-
sendInsertQuery
Inserts the given model into the storage and returnstrueif the query is successful orfalseif an error occurs or the service needs too much time to respond.- Parameters:
model- RDF model containing triples that should be insertedgraphURI- URI of the graph in which the model should be inserted- Returns:
- flag indicating whether the query has been executed successfully or not
-
close
Closes the internal
rpcClientinstance.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-