org.apache.zookeeper
Class ClientCnxn

java.lang.Object
  extended by org.apache.zookeeper.ClientCnxn

public class ClientCnxn
extends Object

This class manages the socket i/o for the client. ClientCnxn maintains a list of available servers to connect to and "transparently" switches servers it is connected to as needed.


Field Summary
static int packetLen
           
 ZooKeeperSaslClient zooKeeperSaslClient
           
 
Constructor Summary
ClientCnxn(String chrootPath, HostProvider hostProvider, int sessionTimeout, ZooKeeper zooKeeper, ClientWatchManager watcher, org.apache.zookeeper.ClientCnxnSocket clientCnxnSocket, boolean canBeReadOnly)
          Creates a connection object.
ClientCnxn(String chrootPath, HostProvider hostProvider, int sessionTimeout, ZooKeeper zooKeeper, ClientWatchManager watcher, org.apache.zookeeper.ClientCnxnSocket clientCnxnSocket, long sessionId, byte[] sessionPasswd, boolean canBeReadOnly)
          Creates a connection object.
 
Method Summary
 void addAuthInfo(String scheme, byte[] auth)
           
 void close()
          Close the connection, which includes; send session disconnect to the server, shutdown the send/event threads.
 void disconnect()
          Shutdown the send/event threads.
static boolean getDisableAutoResetWatch()
          tests use this to check on reset of watches
 long getSessionId()
           
 byte[] getSessionPasswd()
           
 int getSessionTimeout()
           
 void queuePacket(RequestHeader h, ReplyHeader r, org.apache.jute.Record request, org.apache.jute.Record response, AsyncCallback cb)
           
static void setDisableAutoResetWatch(boolean b)
          tests use this to set the auto reset
 void start()
           
 ReplyHeader submitRequest(RequestHeader h, org.apache.jute.Record request, org.apache.jute.Record response, org.apache.zookeeper.ZooKeeper.WatchRegistration watchRegistration)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

zooKeeperSaslClient

public ZooKeeperSaslClient zooKeeperSaslClient

packetLen

public static final int packetLen
Constructor Detail

ClientCnxn

public ClientCnxn(String chrootPath,
                  HostProvider hostProvider,
                  int sessionTimeout,
                  ZooKeeper zooKeeper,
                  ClientWatchManager watcher,
                  org.apache.zookeeper.ClientCnxnSocket clientCnxnSocket,
                  boolean canBeReadOnly)
           throws IOException
Creates a connection object. The actual network connect doesn't get established until needed. The start() instance method must be called subsequent to construction.

Parameters:
chrootPath - - the chroot of this client. Should be removed from this Class in ZOOKEEPER-838
hostProvider - the list of ZooKeeper servers to connect to
sessionTimeout - the timeout for connections.
zooKeeper - the zookeeper object that this connection is related to.
watcher - watcher for this connection
clientCnxnSocket - the socket implementation used (e.g. NIO/Netty)
canBeReadOnly - whether the connection is allowed to go to read-only mode in case of partitioning
Throws:
IOException

ClientCnxn

public ClientCnxn(String chrootPath,
                  HostProvider hostProvider,
                  int sessionTimeout,
                  ZooKeeper zooKeeper,
                  ClientWatchManager watcher,
                  org.apache.zookeeper.ClientCnxnSocket clientCnxnSocket,
                  long sessionId,
                  byte[] sessionPasswd,
                  boolean canBeReadOnly)
Creates a connection object. The actual network connect doesn't get established until needed. The start() instance method must be called subsequent to construction.

Parameters:
chrootPath - - the chroot of this client. Should be removed from this Class in ZOOKEEPER-838
hostProvider - the list of ZooKeeper servers to connect to
sessionTimeout - the timeout for connections.
zooKeeper - the zookeeper object that this connection is related to.
watcher - watcher for this connection
clientCnxnSocket - the socket implementation used (e.g. NIO/Netty)
sessionId - session id if re-establishing session
sessionPasswd - session passwd if re-establishing session
canBeReadOnly - whether the connection is allowed to go to read-only mode in case of partitioning
Throws:
IOException
Method Detail

getSessionId

public long getSessionId()

getSessionPasswd

public byte[] getSessionPasswd()

getSessionTimeout

public int getSessionTimeout()

toString

public String toString()
Overrides:
toString in class Object

queuePacket

public void queuePacket(RequestHeader h,
                        ReplyHeader r,
                        org.apache.jute.Record request,
                        org.apache.jute.Record response,
                        AsyncCallback cb)

getDisableAutoResetWatch

public static boolean getDisableAutoResetWatch()
tests use this to check on reset of watches

Returns:
if the auto reset of watches are disabled

setDisableAutoResetWatch

public static void setDisableAutoResetWatch(boolean b)
tests use this to set the auto reset

Parameters:
b - the value to set disable watches to

start

public void start()

disconnect

public void disconnect()
Shutdown the send/event threads. This method should not be called directly - rather it should be called as part of close operation. This method is primarily here to allow the tests to verify disconnection behavior.


close

public void close()
           throws IOException
Close the connection, which includes; send session disconnect to the server, shutdown the send/event threads.

Throws:
IOException

submitRequest

public ReplyHeader submitRequest(RequestHeader h,
                                 org.apache.jute.Record request,
                                 org.apache.jute.Record response,
                                 org.apache.zookeeper.ZooKeeper.WatchRegistration watchRegistration)
                          throws InterruptedException
Throws:
InterruptedException

addAuthInfo

public void addAuthInfo(String scheme,
                        byte[] auth)


Copyright © 2011 The Apache Software Foundation