Package org.rostore.client
Class RoStoreClient
java.lang.Object
org.rostore.client.RoStoreClient
The major object to access the remote rostore service.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionRoStoreClient
(TrustManager[] trustManagers, RoStoreClientProperties roStoreProperties) Creates a new rostore clientRoStoreClient
(RoStoreClientProperties roStoreProperties) -
Method Summary
Modifier and TypeMethodDescriptionCreates a base request properties for the given pathboolean
delete
(RequestProperties requestProperties) Executes a delete command<T> T
get
(RequestProperties requestProperties, Function<org.apache.hc.client5.http.impl.classic.CloseableHttpResponse, T> deserializer) Executes a get request on the rostoreReturns object that manage the api keysbyte[]
getBytes
(RequestProperties requestProperties) Executes the request on rostore and return the response as byte arrayprotected org.apache.hc.client5.http.io.HttpClientConnectionManager
getEOLHeader
(org.apache.hc.client5.http.impl.classic.CloseableHttpResponse response) Extracts eol header from the server response<K> GeneralContainer
<K> getGeneralContainer
(String name) Creates objectGeneralContainer
.<K> GeneralContainer
<K> getGeneralContainer
(String name, KeySerializer<K> keySerializer) Creates objectGeneralContainer
.static InputStream
getInputStream
(org.apache.hc.client5.http.impl.classic.CloseableHttpResponse response) <K> MappedContainer
<K> getMappedContainer
(String name, Mapper mapper) Creates a new light-weight object that represents access to the container.<K> MappedContainer
<K> getMappedContainer
(String name, Mapper mapper, KeySerializer<K> keySerializer) Creates a new light-weight object that represents access to the container.Returns the rostore connection propertiesgetString
(RequestProperties requestProperties) Executes the request on rostore and return the response as string (UTF-8)static Long
getVersionHeader
(org.apache.hc.client5.http.impl.classic.CloseableHttpResponse response) Extracts version header from the server responseString[]
Get the list of all container names on the remote serviceboolean
ping()
Checks that the server is up and running<T> T
post
(RequestProperties requestProperties, InputStream data, Function<org.apache.hc.client5.http.impl.classic.CloseableHttpResponse, T> deserializer) Executes a post request on the rostore<T> T
put
(RequestProperties requestProperties, InputStream data, Function<org.apache.hc.client5.http.impl.classic.CloseableHttpResponse, T> deserializer) Executes a put request on the rostorevoid
shutdown()
Stops the server
-
Field Details
-
HEADER_VERSION
- See Also:
-
HEADER_EOL
- See Also:
-
HEADER_OPTIONS
- See Also:
-
HEADER_TRACKING_ID
- See Also:
-
HEADER_API_KEY
- See Also:
-
HEADER_CONTENT_TYPE
- See Also:
-
PATH__PING
- See Also:
-
PATH__SHUTDOWN
- See Also:
-
PATH__MAPPER_PROPERTIES
- See Also:
-
PATH__VERSION
- See Also:
-
-
Constructor Details
-
RoStoreClient
Creates a new rostore clientIt is recommended to create one instance of this type for each rostore connection with specific base url and api key
- Parameters:
roStoreProperties
-
-
RoStoreClient
-
-
Method Details
-
getJsonMapper
-
getNativeMapper
-
listContainers
Get the list of all container names on the remote service- Returns:
- the array of all container names
-
getMappedContainer
Creates a new light-weight object that represents access to the container.All value objects will be mapped by the provided
Mapper
.Keys are mapped by
Object.toString()
.- Type Parameters:
K
- type of the key- Parameters:
name
- the name of the containermapper
- the mapper to map the value objects from services- Returns:
- the mapped container
-
getMappedContainer
public <K> MappedContainer<K> getMappedContainer(String name, Mapper mapper, KeySerializer<K> keySerializer) Creates a new light-weight object that represents access to the container.All value objects will be mapped by the provided
Mapper
.Keys will by mapped by
KeySerializer
.- Type Parameters:
K
- type of the key- Parameters:
name
- the name of the containermapper
- the mapper to map the value objects from services- Returns:
- the mapped container
-
getGeneralContainer
Creates objectGeneralContainer
. Container itself is not created or opened, user respective function on the object itself.- Type Parameters:
K
- type of the key- Parameters:
name
- name of the container- Returns:
- the general container
-
getGeneralContainer
Creates objectGeneralContainer
.Container itself is not created or opened, user respective function on the object itself.
This function will create a new object every time the call is done. The caller may decide to store it and reuse on every operation.
This object is very light-weight.
- Type Parameters:
K
- type of the key- Parameters:
name
- name of the containerkeySerializer
- serializer for the key object or null (in later case theDefaultKeySerializer
is used)- Returns:
- container
-
getApiKeys
Returns object that manage the api keys- Returns:
- api keys object
-
ping
public boolean ping()Checks that the server is up and running- Returns:
true
if server answers the ping request
-
shutdown
public void shutdown()Stops the server -
create
Creates a base request properties for the given path- Parameters:
path
- the path for the call- Returns:
- the request properties object
-
getProperties
Returns the rostore connection properties- Returns:
- properties
-
getConnectionManager
protected org.apache.hc.client5.http.io.HttpClientConnectionManager getConnectionManager() -
get
public <T> T get(RequestProperties requestProperties, Function<org.apache.hc.client5.http.impl.classic.CloseableHttpResponse, T> deserializer) Executes a get request on the rostore- Type Parameters:
T
- type of the object- Parameters:
requestProperties
- request parametersdeserializer
- reads from server and transforms the data to object- Returns:
- object from the server
-
delete
Executes a delete command- Parameters:
requestProperties
- request parameters- Returns:
true
if delete request was successful
-
getBytes
Executes the request on rostore and return the response as byte array- Parameters:
requestProperties
- the request properties- Returns:
- the data
-
getString
Executes the request on rostore and return the response as string (UTF-8)- Parameters:
requestProperties
- the request properties- Returns:
- the data as string
-
post
public <T> T post(RequestProperties requestProperties, InputStream data, Function<org.apache.hc.client5.http.impl.classic.CloseableHttpResponse, T> deserializer) Executes a post request on the rostore- Type Parameters:
T
- type of the object- Parameters:
requestProperties
- request parametersdata
- to post on the serverdeserializer
- reads server's response and transforms the data to object- Returns:
- object from the server
-
put
public <T> T put(RequestProperties requestProperties, InputStream data, Function<org.apache.hc.client5.http.impl.classic.CloseableHttpResponse, T> deserializer) Executes a put request on the rostore- Type Parameters:
T
- type of the object- Parameters:
requestProperties
- request parametersdata
- data to put on the serverdeserializer
- reads server's response and transforms the data to object- Returns:
- object from the server
-
getVersionHeader
public static Long getVersionHeader(org.apache.hc.client5.http.impl.classic.CloseableHttpResponse response) Extracts version header from the server response- Parameters:
response
- the server response- Returns:
- version
-
getEOLHeader
Extracts eol header from the server response- Parameters:
response
- the server response- Returns:
- eol value
-
getInputStream
public static InputStream getInputStream(org.apache.hc.client5.http.impl.classic.CloseableHttpResponse response)
-