Interface GridClient

  • All Superinterfaces:
    AutoCloseable
    All Known Implementing Classes:
    GridClientImpl, GridRouterClientImpl

    public interface GridClient
    extends AutoCloseable
    Ignite Java client API.

    Contains functionality to get projections for accessing remote data and compute functionality, as well as provide listeners on topology changes.

    You can obtain an instance of GridClient through GridClientFactory.start(GridClientConfiguration). Note that you can have multiple instances of GridClient running in the same VM. For information on how to start or stop Grid please refer to GridClientFactory class.

    Use the following method to get access to remote cache functionality:

    Use following methods to get access to remote compute functionality:

    Partition awareness

    One of the unique properties of the Ignite remote clients is that they are affinity aware. In other words, both compute and data APIs will optionally contact exactly the node where the data is cached based on some affinity key. This allows for collocation of computations and data and avoids extra network hops that would be necessary if non-affinity nodes were contacted.

    If client can't access some of grid nodes directly (for example due to security restrictions) either dedicated Router component could be used or some of Grid nodes could act as routers. See GridClientConfiguration.getRouters() for more details.

    See Also:
    GridClientCompute, GridClientData
    • Method Detail

      • id

        UUID id()
        Gets a unique client identifier. This identifier is generated by factory on client creation and used in identification and authentication procedure on server node.
        Returns:
        Generated client id.
      • data

        GridClientData data​(String cacheName)
                     throws GridClientException
        Gets a data projection for grid cache with name cacheName. If no data configuration with given name was provided at client startup, an exception will be thrown.
        Parameters:
        cacheName - Grid cache name for which data projection should be obtained.
        Returns:
        Data projection for grid cache with name cacheName.
        Throws:
        GridClientException - If client was closed or no configuration with given name was provided.
      • compute

        GridClientCompute compute()
        Gets a default compute projection. Default compute projection will include all nodes in remote grid. Selection of node that will be connected to perform operations will be done according to GridClientLoadBalancer provided in client configuration or according to affinity if projection call involves affinity key.

        More restricted projection configurations may be created with GridClientCompute methods.

        Returns:
        Default compute projection.
        See Also:
        GridClientCompute
      • removeTopologyListener

        void removeTopologyListener​(GridClientTopologyListener lsnr)
        Removes previously added topology listener.
        Parameters:
        lsnr - Listener to remove.
      • connected

        boolean connected()
        Indicates whether client is connected to remote Grid. In other words it allow to determine if client is able to communicate with Grid right now. If it can't all methods on Compute and Data projections throw GridClientDisconnectedException.

        Connection status is updated in background together with topology update. See GridClientConfiguration.getTopologyRefreshFrequency() for more details on how background topology update works.

        Note that due to asynchronous nature of topology update and connectivity detection this method gives no guarantees for subsequent calls for projections methods. It can be used only fo diagnostic and monitoring purposes.

        Returns:
        Whether client is connected to remote Grid.
      • checkLastError

        GridClientException checkLastError()
        Check for last topology errors.
        Returns:
        Exception if client was not connected.