Class RoStoreClient

java.lang.Object
org.rostore.client.RoStoreClient

public class RoStoreClient extends Object
The major object to access the remote rostore service.
  • Field Details

  • Constructor Details

    • RoStoreClient

      public RoStoreClient(TrustManager[] trustManagers, RoStoreClientProperties roStoreProperties)
      Creates a new rostore client

      It is recommended to create one instance of this type for each rostore connection with specific base url and api key

      Parameters:
      roStoreProperties -
    • RoStoreClient

      public RoStoreClient(RoStoreClientProperties roStoreProperties)
  • Method Details

    • getJsonMapper

      public JsonMapper getJsonMapper()
    • getNativeMapper

      public NativeMapper getNativeMapper()
    • listContainers

      public String[] listContainers()
      Get the list of all container names on the remote service
      Returns:
      the array of all container names
    • getMappedContainer

      public <K> MappedContainer<K> getMappedContainer(String name, Mapper mapper)
      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 container
      mapper - 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 container
      mapper - the mapper to map the value objects from services
      Returns:
      the mapped container
    • getGeneralContainer

      public <K> GeneralContainer<K> getGeneralContainer(String name)
      Creates object GeneralContainer. 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

      public <K> GeneralContainer<K> getGeneralContainer(String name, KeySerializer<K> keySerializer)
      Creates object GeneralContainer.

      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 container
      keySerializer - serializer for the key object or null (in later case the DefaultKeySerializer is used)
      Returns:
      container
    • getApiKeys

      public ApiKeys 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

      public RequestProperties create(String path)
      Creates a base request properties for the given path
      Parameters:
      path - the path for the call
      Returns:
      the request properties object
    • getProperties

      public RoStoreClientProperties 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 parameters
      deserializer - reads from server and transforms the data to object
      Returns:
      object from the server
    • delete

      public boolean delete(RequestProperties requestProperties)
      Executes a delete command
      Parameters:
      requestProperties - request parameters
      Returns:
      true if delete request was successful
    • getBytes

      public byte[] getBytes(RequestProperties requestProperties)
      Executes the request on rostore and return the response as byte array
      Parameters:
      requestProperties - the request properties
      Returns:
      the data
    • getString

      public String getString(RequestProperties requestProperties)
      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 parameters
      data - to post on the server
      deserializer - 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 parameters
      data - data to put on the server
      deserializer - 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

      public Long getEOLHeader(org.apache.hc.client5.http.impl.classic.CloseableHttpResponse response)
      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)