|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.w3c.jigsaw.http.socket.SocketClientFactory
public class SocketClientFactory
The client pool is a kind of client factory. Each time the server gets a new connection, it calls the client pool to bound a client object (newly created or spared) to handle it.
Field Summary | |
---|---|
static int |
AVG_DEAD
|
static int |
AVG_HIGH
|
static int |
AVG_LIGHT
|
static int |
AVG_NORMAL
|
static java.lang.String |
BINDADDR_P
|
static int |
IDLETO
|
static java.lang.String |
IDLETO_P
|
static int |
MAXCLIENTS
|
static java.lang.String |
MAXCLIENTS_P
|
static int |
MAXSPARE_FREE
|
static java.lang.String |
MAXSPARE_FREE_P
|
static int |
MAXSPARE_IDLE
|
static java.lang.String |
MAXSPARE_IDLE_P
|
static int |
MAXTHREADS
|
static java.lang.String |
MAXTHREADS_P
|
static int |
MINSPARE_FREE
|
static java.lang.String |
MINSPARE_FREE_P
|
static java.lang.String |
TIMEOUT_P
|
Constructor Summary | |
---|---|
SocketClientFactory()
Empty constructor for dynamic class instantiation. |
Method Summary | |
---|---|
protected SocketClientState |
addClient(boolean free)
Create a new client for this pool. |
protected boolean |
clientConnectionFinished(SocketClient client)
Notify that this client has finished with its connection. |
protected void |
clientFinished(SocketClient client)
Notify that this client has been killed. |
protected SocketClient |
createClient(httpd server,
SocketClientState state)
Factory for creating a new client for this pool. |
java.net.ServerSocket |
createServerSocket()
Create the master socket for this client factory. |
protected void |
deleteClient(SocketClientState cs)
Remove this client state from the glohbal client list. |
java.lang.String |
getHTMLStatus()
Give the status of this class as a partial HTML text which will be added into a block level element |
void |
handleConnection(java.net.Socket socket)
Handle the given connection. |
protected boolean |
idleClientRemove(SocketClient client)
Removes an idle client from the list, updates only the idle list as the free count has already be accessed |
void |
initialize(httpd server)
Initialize the raw, client socket factory. |
protected void |
killClients(boolean force)
|
protected void |
killSomeClients()
|
protected void |
killSomeClients(int howmany)
|
protected boolean |
notifyIdle(SocketClient client)
The client notifies the pool that it enters idle state. |
protected void |
notifyUse(SocketClient client)
The client notifies the pool that is has been activated. |
boolean |
propertyChanged(java.lang.String name)
Some property have changed, update our setting. |
protected void |
run(SocketClient client)
|
void |
shutdown(boolean force)
Shutdown the client pool. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MINSPARE_FREE
public static final int MAXSPARE_FREE
public static final int MAXSPARE_IDLE
public static final int MAXTHREADS
public static final int MAXCLIENTS
public static final int IDLETO
public static final int AVG_LIGHT
public static final int AVG_NORMAL
public static final int AVG_HIGH
public static final int AVG_DEAD
public static final java.lang.String MINSPARE_FREE_P
public static final java.lang.String MAXSPARE_FREE_P
public static final java.lang.String MAXSPARE_IDLE_P
public static final java.lang.String MAXTHREADS_P
public static final java.lang.String MAXCLIENTS_P
public static final java.lang.String IDLETO_P
public static final java.lang.String BINDADDR_P
public static final java.lang.String TIMEOUT_P
Constructor Detail |
---|
public SocketClientFactory()
Method Detail |
---|
public java.lang.String getHTMLStatus()
getHTMLStatus
in interface Status
public boolean propertyChanged(java.lang.String name)
propertyChanged
in interface PropertyMonitoring
name
- The name of the property that has changed.
protected void deleteClient(SocketClientState cs)
cs
- The client state to remove from the list.protected SocketClient createClient(httpd server, SocketClientState state)
server
- the target http daemonstate
- the client state holder
protected SocketClientState addClient(boolean free)
free
- A boolean, if true the client is inserted
straight into the free list, otherwise, it is not plugged into any
list.
protected boolean idleClientRemove(SocketClient client)
the
- socket client to remove from the idle listprotected boolean clientConnectionFinished(SocketClient client)
client
- The client that is done with its connection.protected void clientFinished(SocketClient client)
client
- The client that has terminate.protected void notifyUse(SocketClient client)
This method needs not be synchronized, as it affect only the client state, not the client list.
client
- The activated client.protected boolean notifyIdle(SocketClient client)
This method needs not be synchronized, as it affect only the client state, not the client list.
client
- The client that is going to be idle.protected void killSomeClients(int howmany)
protected final void killSomeClients()
protected void run(SocketClient client)
public void handleConnection(java.net.Socket socket)
A client enters the LRU list (and become a candidate for kill) only
after it has handle one request (or if some timeout expires). This is
performed by the first call to notifyUse
which will
silently insert the client into the LRU if it was not there already.
This client pool does a lot of nice thinigs, but could probably be implemented in a much better way (while keeping the features it has). Contention arond the pool is probably concern number 1 of performances.
handleConnection
in interface ClientFactory
socket
- The connection to handle.protected void killClients(boolean force)
public void shutdown(boolean force)
shutdown
in interface ClientFactory
force
- Should we interrupt running clients.public java.net.ServerSocket createServerSocket() throws java.io.IOException
createServerSocket
in interface ClientFactory
java.io.IOException
- If some IO error occurs while creating the
server socket.public void initialize(httpd server)
initialize
in interface ClientFactory
server
- The server context we are attached to.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |