com.hazelcast.client.connection.nio
Class ClientConnectionManagerImpl

java.lang.Object
  extended by com.hazelcast.client.connection.nio.ClientConnectionManagerImpl
All Implemented Interfaces:
ClientConnectionManager

public class ClientConnectionManagerImpl
extends Object
implements ClientConnectionManager


Nested Class Summary
 class ClientConnectionManagerImpl.ManagerAuthenticator
           
 
Constructor Summary
ClientConnectionManagerImpl(HazelcastClientInstanceImpl client, LoadBalancer loadBalancer, AddressTranslator addressTranslator)
           
 
Method Summary
 ClientConnection connectToAddress(Address target)
           
 String getUuid()
           
 void handlePacket(Packet packet)
          Handles incoming network package
 boolean isAlive()
          Check if client connection manager is alive.
 int newCallId()
          Next unique call id for request
 void onCloseOwnerConnection()
          Called when an owner connection is closed
 void onConnectionClose(ClientConnection clientConnection)
          Called when an connection is closed.
 void onDetectingUnresponsiveConnection(ClientConnection connection)
          Called heartbeat timeout is detected on a connection.
 ClientConnection ownerConnection(Address address)
          Creates a new owner connection to given address
 void removeEndpoint(Address address)
          Called when a member left the cluster
 boolean removeEventHandler(Integer callId)
          Removes event handler corresponding to callId from responsible ClientConnection
 Object sendAndReceive(ClientRequest request, ClientConnection connection)
          Sends request and waits for response
 void shutdown()
          Shutdown clientConnectionManager
 void start()
          Start clientConnectionManager
 ClientConnection tryToConnect(Address target)
          Tries to connect to an address in member list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientConnectionManagerImpl

public ClientConnectionManagerImpl(HazelcastClientInstanceImpl client,
                                   LoadBalancer loadBalancer,
                                   AddressTranslator addressTranslator)
Method Detail

isAlive

public boolean isAlive()
Description copied from interface: ClientConnectionManager
Check if client connection manager is alive. ClientConnectionManager is not alive only when client is closing.

Specified by:
isAlive in interface ClientConnectionManager
Returns:
true if alive, false otherwise.

start

public void start()
Description copied from interface: ClientConnectionManager
Start clientConnectionManager

Specified by:
start in interface ClientConnectionManager

shutdown

public void shutdown()
Description copied from interface: ClientConnectionManager
Shutdown clientConnectionManager

Specified by:
shutdown in interface ClientConnectionManager

onCloseOwnerConnection

public void onCloseOwnerConnection()
Description copied from interface: ClientConnectionManager
Called when an owner connection is closed

Specified by:
onCloseOwnerConnection in interface ClientConnectionManager

ownerConnection

public ClientConnection ownerConnection(Address address)
                                 throws IOException
Description copied from interface: ClientConnectionManager
Creates a new owner connection to given address

Specified by:
ownerConnection in interface ClientConnectionManager
Parameters:
address - to be connection to established
Returns:
ownerConnection
Throws:
IOException

connectToAddress

public ClientConnection connectToAddress(Address target)
                                  throws Exception
Specified by:
connectToAddress in interface ClientConnectionManager
Throws:
Exception

tryToConnect

public ClientConnection tryToConnect(Address target)
                              throws Exception
Description copied from interface: ClientConnectionManager
Tries to connect to an address in member list. Gets an address a hint first tries that if not successful, tries connections from LoadBalancer

Specified by:
tryToConnect in interface ClientConnectionManager
Parameters:
target - hintAddress
Returns:
authenticated connection
Throws:
Exception - authentication failed or no connection found

getUuid

public String getUuid()
Specified by:
getUuid in interface ClientConnectionManager
Returns:
unique uuid of local client if available, null otherwise

onConnectionClose

public void onConnectionClose(ClientConnection clientConnection)
Description copied from interface: ClientConnectionManager
Called when an connection is closed. Clears related resources of given clientConnection.

Specified by:
onConnectionClose in interface ClientConnectionManager
Parameters:
clientConnection - closed connection

removeEventHandler

public boolean removeEventHandler(Integer callId)
Description copied from interface: ClientConnectionManager
Removes event handler corresponding to callId from responsible ClientConnection

Specified by:
removeEventHandler in interface ClientConnectionManager
Parameters:
callId - of event handler registration request
Returns:
true if found and removed, false otherwise

handlePacket

public void handlePacket(Packet packet)
Description copied from interface: ClientConnectionManager
Handles incoming network package

Specified by:
handlePacket in interface ClientConnectionManager
Parameters:
packet - to be processed

newCallId

public int newCallId()
Description copied from interface: ClientConnectionManager
Next unique call id for request

Specified by:
newCallId in interface ClientConnectionManager
Returns:
new unique callId

sendAndReceive

public Object sendAndReceive(ClientRequest request,
                             ClientConnection connection)
                      throws Exception
Description copied from interface: ClientConnectionManager
Sends request and waits for response

Specified by:
sendAndReceive in interface ClientConnectionManager
Parameters:
request - to be send
connection - to send the request over
Returns:
response of request
Throws:
Exception - if a network connection occurs or response is an exception

removeEndpoint

public void removeEndpoint(Address address)
Description copied from interface: ClientConnectionManager
Called when a member left the cluster

Specified by:
removeEndpoint in interface ClientConnectionManager
Parameters:
address - address of the member

onDetectingUnresponsiveConnection

public void onDetectingUnresponsiveConnection(ClientConnection connection)
Description copied from interface: ClientConnectionManager
Called heartbeat timeout is detected on a connection.

Specified by:
onDetectingUnresponsiveConnection in interface ClientConnectionManager
Parameters:
connection - to be marked.


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