cebit.server.idm.socket
Class IDMSocketClientFactory

java.lang.Object
  |
  +--cebit.server.idm.socket.IDMSocketClientFactory
All Implemented Interfaces:
idman.rules.ChainEvaluationListener, org.w3c.jigsaw.http.ClientFactory, org.ssonet.net.ConnectionListener, org.w3c.util.PropertyMonitoring, org.ssonet.net.SSONETContextFactory, org.w3c.util.Status

public class IDMSocketClientFactory
extends java.lang.Object
implements org.w3c.jigsaw.http.ClientFactory, org.w3c.util.PropertyMonitoring, org.w3c.util.Status, org.ssonet.net.SSONETContextFactory, idman.rules.ChainEvaluationListener, org.ssonet.net.ConnectionListener

This class handles the SSONET connections to this server, and it creates a ServerSocket for receiving connections.

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
(package private)  boolean alive
           
static int AVG_DEAD
           
static int AVG_HIGH
           
static int AVG_LIGHT
           
static int AVG_NORMAL
           
(package private)  java.net.InetAddress bindAddr
          the daemon (Server) bind address for this factory
static java.lang.String BINDADDR_P
          Property name for internet address, where jigsaw is bound to.
(package private)  int busyCount
           
protected  org.ssonet.net.CertificateListener certificateListener
          The default certificate Listener used for all connections
(package private)  int clientCount
           
(package private)  int clientEstim
           
(package private)  int count
           
(package private)  cebit.server.idm.socket.IDMSocketClientState csList
           
(package private)  int freeCount
           
(package private)  org.w3c.util.LRUList freeList
           
(package private)  int idleCount
           
(package private)  org.w3c.util.LRUList idleList
           
static int IDLETO
           
static java.lang.String IDLETO_P
          Property name for the the timeout for idle clients, after which the connection is closed.
(package private)  int loadavg
           
(package private)  int maxClients
          the maximum number of clients
static int MAXCLIENTS
           
static java.lang.String MAXCLIENTS_P
          Property name for the maximum number of clients allowed.
(package private)  int maxFree
           
(package private)  int maxIdle
           
static int MAXSPARE_FREE
           
static java.lang.String MAXSPARE_FREE_P
          Property name for the maximum of free clients, which are allowed.
static int MAXSPARE_IDLE
           
static java.lang.String MAXSPARE_IDLE_P
          Property name for the maximum of idle (connected, but waiting for new requests) clients, which are allowed.
static int MAXTHREADS
           
static java.lang.String MAXTHREADS_P
          Property name for the maximum number of threads, which might be used for Jigsaw.
(package private)  int minFree
           
static int MINSPARE_FREE
           
static java.lang.String MINSPARE_FREE_P
          Property name for the minimum number of free clients, which must be available.
(package private)  org.w3c.util.ObservableProperties props
           
(package private)  org.w3c.jigsaw.http.httpd server
          the daemon (Server) of this factory
(package private)  org.w3c.util.ThreadCache threadcache
           
 
Fields inherited from interface org.ssonet.net.ConnectionListener
FINISHED_STATE, INIT_STATE, MECHANISMS_NEGOTIATION, NOT_STARTED_STATE, RUNNING_STATE, SECURITY_GOAL_NEGOTIATION
 
Constructor Summary
IDMSocketClientFactory()
          default constructor of this factory
 
Method Summary
protected  cebit.server.idm.socket.IDMSocketClientState addClient(boolean free)
          Create a new IDMSocketClient for the pool.
protected  boolean clientConnectionFinished(cebit.server.idm.socket.IDMSocketClient client)
          X--X Notify that this client has finished with its connection.
protected  void clientFinished(cebit.server.idm.socket.IDMSocketClient client)
          X--X Notify that this client has been killed.
 void connectionStateChanged(org.ssonet.net.SSONETContext context, int currentState)
           
 org.ssonet.net.SSONETContext createContext()
          Creates a SSONETContext (Method of SSONETContextFactory)
 java.net.ServerSocket createServerSocket()
          method for creating a SSONET server socket
 boolean decideSecurityGoal(int securityGoal, org.ssonet.net.ActionConfiguration ownConfiguration, org.ssonet.net.SSONETContext context)
          Handles a solvable conflict during security goal negotiation
protected  void deleteClient(cebit.server.idm.socket.IDMSocketClientState cs)
          X--X Remove this client state from the glohbal client list.
 boolean doWarning(java.lang.String chainname, idman.rules.Condition cond, java.lang.String id, byte[] content, idman.mngt.Context context, java.lang.String parameter)
          Receive warnings from ChainEvaluator for finding the Pseudonym for receiving requests.
 java.lang.String getHTMLStatus()
          X--X 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)
          X--X Handle the given connection.
protected  boolean idleClientRemove(cebit.server.idm.socket.IDMSocketClient client)
          X--X Removes an idle client from the list, updates only the idle list as the free count has already be accessed
 void initialize(org.w3c.jigsaw.http.httpd server)
          method for intializing this factory
protected  void killClients(boolean force)
           
protected  void killSomeClients()
           
protected  void killSomeClients(int howmany)
           
 void negotiationRequestReceived(org.ssonet.net.SSONETContext context, int negotiationType)
           
protected  boolean notifyIdle(cebit.server.idm.socket.IDMSocketClient client)
          X--X The client notifies the pool that it enters idle state.
protected  void notifyUse(cebit.server.idm.socket.IDMSocketClient client)
          X--X The client notifies the pool that is has been activated.
 boolean propertyChanged(java.lang.String name)
          method for handling a dynamic property modification
protected  void run(cebit.server.idm.socket.IDMSocketClient 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

certificateListener

protected org.ssonet.net.CertificateListener certificateListener
The default certificate Listener used for all connections


server

org.w3c.jigsaw.http.httpd server
the daemon (Server) of this factory


bindAddr

java.net.InetAddress bindAddr
the daemon (Server) bind address for this factory


maxClients

int maxClients
the maximum number of clients


MINSPARE_FREE

public static final int MINSPARE_FREE
See Also:
Constant Field Values

MAXSPARE_FREE

public static final int MAXSPARE_FREE
See Also:
Constant Field Values

MAXSPARE_IDLE

public static final int MAXSPARE_IDLE
See Also:
Constant Field Values

MAXTHREADS

public static final int MAXTHREADS
See Also:
Constant Field Values

MAXCLIENTS

public static final int MAXCLIENTS
See Also:
Constant Field Values

IDLETO

public static final int IDLETO
See Also:
Constant Field Values

AVG_LIGHT

public static final int AVG_LIGHT
See Also:
Constant Field Values

AVG_NORMAL

public static final int AVG_NORMAL
See Also:
Constant Field Values

AVG_HIGH

public static final int AVG_HIGH
See Also:
Constant Field Values

AVG_DEAD

public static final int AVG_DEAD
See Also:
Constant Field Values

MINSPARE_FREE_P

public static final java.lang.String MINSPARE_FREE_P
Property name for the minimum number of free clients, which must be available.

See Also:
Constant Field Values

MAXSPARE_FREE_P

public static final java.lang.String MAXSPARE_FREE_P
Property name for the maximum of free clients, which are allowed.

See Also:
Constant Field Values

MAXSPARE_IDLE_P

public static final java.lang.String MAXSPARE_IDLE_P
Property name for the maximum of idle (connected, but waiting for new requests) clients, which are allowed.

See Also:
Constant Field Values

MAXTHREADS_P

public static final java.lang.String MAXTHREADS_P
Property name for the maximum number of threads, which might be used for Jigsaw.

See Also:
Constant Field Values

MAXCLIENTS_P

public static final java.lang.String MAXCLIENTS_P
Property name for the maximum number of clients allowed.

See Also:
Constant Field Values

IDLETO_P

public static final java.lang.String IDLETO_P
Property name for the the timeout for idle clients, after which the connection is closed.

See Also:
Constant Field Values

BINDADDR_P

public static final java.lang.String BINDADDR_P
Property name for internet address, where jigsaw is bound to.

See Also:
Constant Field Values

minFree

int minFree

maxFree

int maxFree

maxIdle

int maxIdle

count

int count

props

org.w3c.util.ObservableProperties props

busyCount

int busyCount

idleList

org.w3c.util.LRUList idleList

freeList

org.w3c.util.LRUList freeList

csList

cebit.server.idm.socket.IDMSocketClientState csList

idleCount

int idleCount

freeCount

int freeCount

clientCount

int clientCount

clientEstim

int clientEstim

threadcache

org.w3c.util.ThreadCache threadcache

loadavg

int loadavg

alive

boolean alive
Constructor Detail

IDMSocketClientFactory

public IDMSocketClientFactory()
default constructor of this factory

Method Detail

createServerSocket

public java.net.ServerSocket createServerSocket()
                                         throws java.io.IOException
method for creating a SSONET server socket

Specified by:
createServerSocket in interface org.w3c.jigsaw.http.ClientFactory
Returns:
a new server socket instance
java.io.IOException

initialize

public void initialize(org.w3c.jigsaw.http.httpd server)
method for intializing this factory

Specified by:
initialize in interface org.w3c.jigsaw.http.ClientFactory
Parameters:
server - the daemon of this factory

createContext

public org.ssonet.net.SSONETContext createContext()
Creates a SSONETContext (Method of SSONETContextFactory)

Specified by:
createContext in interface org.ssonet.net.SSONETContextFactory

decideSecurityGoal

public boolean decideSecurityGoal(int securityGoal,
                                  org.ssonet.net.ActionConfiguration ownConfiguration,
                                  org.ssonet.net.SSONETContext context)
Handles a solvable conflict during security goal negotiation

Specified by:
decideSecurityGoal in interface org.ssonet.net.ConnectionListener

doWarning

public boolean doWarning(java.lang.String chainname,
                         idman.rules.Condition cond,
                         java.lang.String id,
                         byte[] content,
                         idman.mngt.Context context,
                         java.lang.String parameter)
Receive warnings from ChainEvaluator for finding the Pseudonym for receiving requests.

Specified by:
doWarning in interface idman.rules.ChainEvaluationListener

addClient

protected cebit.server.idm.socket.IDMSocketClientState addClient(boolean free)
Create a new IDMSocketClient for the pool.

Parameters:
free - A boolean, if true the client is inserted straight into the free list, otherwise, it is not plugged into any list.
Returns:
A SocketClientState instance, if creation of a new client was allowed, null if no more clients could be created.

getHTMLStatus

public java.lang.String getHTMLStatus()
X--X Give the status of this class as a partial HTML text which will be added into a block level element

Specified by:
getHTMLStatus in interface org.w3c.util.Status
Returns:
a String, the generated HTML

propertyChanged

public boolean propertyChanged(java.lang.String name)
method for handling a dynamic property modification

Specified by:
propertyChanged in interface org.w3c.util.PropertyMonitoring
Parameters:
name - the name of the property modified
Returns:
true if and only if the modification has been handled successfully

deleteClient

protected void deleteClient(cebit.server.idm.socket.IDMSocketClientState cs)
X--X Remove this client state from the glohbal client list.

Parameters:
cs - The client state to remove from the list.

idleClientRemove

protected boolean idleClientRemove(cebit.server.idm.socket.IDMSocketClient client)
X--X Removes an idle client from the list, updates only the idle list as the free count has already be accessed

Parameters:
client - the socket to remove from the idle list

clientConnectionFinished

protected boolean clientConnectionFinished(cebit.server.idm.socket.IDMSocketClient client)
X--X Notify that this client has finished with its connection. If the pool wants the client to be freed (because it has too many of them), it makes the client kill itself (which will trigger a call to the clientFinished method, were enventual cleanup is performed).

Parameters:
client - The client that is done with its connection.

clientFinished

protected void clientFinished(cebit.server.idm.socket.IDMSocketClient client)
X--X Notify that this client has been killed.

Parameters:
client - The client that has terminate.

notifyUse

protected void notifyUse(cebit.server.idm.socket.IDMSocketClient client)
X--X The client notifies the pool that is has been activated. The client state object is updated to unmark the client as idle.

This method needs not be synchronized, as it affect only the client state, not the client list.

Parameters:
client - The activated client.

notifyIdle

protected boolean notifyIdle(cebit.server.idm.socket.IDMSocketClient client)
X--X The client notifies the pool that it enters idle state.

This method needs not be synchronized, as it affect only the client state, not the client list.

Parameters:
client - The client that is going to be idle.

killSomeClients

protected void killSomeClients(int howmany)

killSomeClients

protected final void killSomeClients()

run

protected void run(cebit.server.idm.socket.IDMSocketClient client)

handleConnection

public void handleConnection(java.net.Socket socket)
X--X Handle the given connection. Find a free client, bind it to the given socket, and run it. If we have reached our maximum allowed number of clients, kill some connections.

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.

Specified by:
handleConnection in interface org.w3c.jigsaw.http.ClientFactory
Parameters:
socket - The connection to handle.

killClients

protected void killClients(boolean force)

shutdown

public void shutdown(boolean force)
Shutdown the client pool. If force is true, kill all running clients right now, otherwise, wait for them to terminate gracefully, and return when done.

Specified by:
shutdown in interface org.w3c.jigsaw.http.ClientFactory
Parameters:
force - Should we interrupt running clients.

negotiationRequestReceived

public void negotiationRequestReceived(org.ssonet.net.SSONETContext context,
                                       int negotiationType)
Specified by:
negotiationRequestReceived in interface org.ssonet.net.ConnectionListener

connectionStateChanged

public void connectionStateChanged(org.ssonet.net.SSONETContext context,
                                   int currentState)
Specified by:
connectionStateChanged in interface org.ssonet.net.ConnectionListener


Copyright © 2003 DRIM Team. All Rights Reserved.