com.hazelcast.client
Class HazelcastClient

java.lang.Object
  extended by com.hazelcast.client.HazelcastClient

public final class HazelcastClient
extends Object

The HazelcastClient is comparable to the Hazelcast class and provides the ability the create and manage Hazelcast clients. Hazelcast clients are HazelcastInstance implementations, so in most cases most of the code is unaware of talking to a cluster member or a client.

Smart vs dumb clients

Hazelcast Client enables you to do all Hazelcast operations without being a member of the cluster. Clients can be:
  1. smart: this means that they immediately can send an operation like map.get(key) to the member that owns that specific key.
  2. dumb: it will connect to a random member in the cluster and send requests to this member. This member then needs to send the request to the correct member.
For more information see ClientNetworkConfig.setSmartRouting(boolean).

High availability

When the connected cluster member dies, client will automatically switch to another live member.


Method Summary
static Collection<HazelcastInstance> getAllHazelcastClients()
          Gets an immutable collection of all client HazelcastInstances created in this JVM.
static HazelcastInstance getHazelcastClientByName(String instanceName)
          Returns an existing HazelcastClient with instanceName.
static HazelcastInstance newHazelcastClient()
           
static HazelcastInstance newHazelcastClient(ClientConfig config)
           
static void shutdown(HazelcastInstance instance)
          Shutdown the provided client and remove it from the managed list
static void shutdown(String instanceName)
          Shutdown the provided client and remove it from the managed list
static void shutdownAll()
          Shuts down all the client HazelcastInstance created in this JVM.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newHazelcastClient

public static HazelcastInstance newHazelcastClient()

newHazelcastClient

public static HazelcastInstance newHazelcastClient(ClientConfig config)

getHazelcastClientByName

public static HazelcastInstance getHazelcastClientByName(String instanceName)
Returns an existing HazelcastClient with instanceName.

Parameters:
instanceName - Name of the HazelcastInstance (client) which can be retrieved by HazelcastInstance.getName()
Returns:
HazelcastInstance

getAllHazelcastClients

public static Collection<HazelcastInstance> getAllHazelcastClients()
Gets an immutable collection of all client HazelcastInstances created in this JVM.

In managed environments such as Java EE or OSGi Hazelcast can be loaded by multiple classloaders. Typically you will get at least one classloader per every application deployed. In these cases only the client HazelcastInstances created by the same application will be seen, and instances created by different applications are invisible.

The returned collection is a snapshot of the client HazelcastInstances. So changes to the client HazelcastInstances will not be visible in this collection.

Returns:
the collection of client HazelcastInstances

shutdownAll

public static void shutdownAll()
Shuts down all the client HazelcastInstance created in this JVM.

To be more precise it shuts down the HazelcastInstances loaded using the same classloader this HazelcastClient has been loaded with. This method is mostly used for testing purposes.

See Also:
getAllHazelcastClients()

shutdown

public static void shutdown(HazelcastInstance instance)
Shutdown the provided client and remove it from the managed list

Parameters:
instance - the hazelcast client instance

shutdown

public static void shutdown(String instanceName)
Shutdown the provided client and remove it from the managed list

Parameters:
instanceName - the hazelcast client instance name


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.