amber.server.manager.connection
Class LoginManager

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--amber.server.manager.connection.LoginManager
All Implemented Interfaces:
ConnectionReceiver, java.lang.Runnable

public class LoginManager
extends java.lang.Thread
implements ConnectionReceiver

Thread to deal with the initial reception of login packets. This object instantiates N Login threads to handle incoming connection requests. This thread reads added connection requests and passes them to the Login thread which is least loaded. The number of threads instantiated is specified by the primary server in the LoginThreadNumber property.

Version:
1.0.0
Author:
Dr. David J. Knowles
See Also:
ConnectionManager, ListenerThread, LoginThread, PropertyTags

Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
LoginManager(ConnectionManager parent, int type)
          Construct the thread, with it's parent class so it may pass back messages.
 
Method Summary
 void addConnection(java.net.Socket socket, int type)
          This function adds a new socket connection to the thread for processing.
protected  void createLoginThreads()
          This function creates the number of login threads as specified in the properties handler.
protected  LoginThread getLightestLogin()
          This function returns the lightest loaded login thread.
 int getType()
          Returns the type of listener this is.
 void run()
          Main implementation function.
protected  void sendToLogin(java.net.Socket socket)
          This function checks the login threads to determine the lightest loaded and adds the incoming connection to the thread.
 void setType(int type)
          Sets the type of listener this is.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LoginManager

public LoginManager(ConnectionManager parent,
                    int type)
Construct the thread, with it's parent class so it may pass back messages.
Parameters:
parent - ConnectionManager parent object.
type - int containing the type of listener this is. This matches the constants in this class.
certificate - RSAKey containing the encryption certificate. This is required for secure connections.
Method Detail

createLoginThreads

protected void createLoginThreads()
This function creates the number of login threads as specified in the properties handler.

addConnection

public void addConnection(java.net.Socket socket,
                          int type)
This function adds a new socket connection to the thread for processing. This function will also waken the thread if it is in a suspended state.
Specified by:
addConnection in interface ConnectionReceiver
Parameters:
socket - Socket which is the incoming connection.
type - int defining the type of connection received. This value corresponds to the constants defined in Listener.
See Also:
Listener

run

public void run()
Main implementation function. It takes the received connections and calls the ConnectionManager to handle the incoming connection.
Overrides:
run in class java.lang.Thread

sendToLogin

protected void sendToLogin(java.net.Socket socket)
This function checks the login threads to determine the lightest loaded and adds the incoming connection to the thread.
Parameters:
socket - the incoming connection to pass on.

getLightestLogin

protected LoginThread getLightestLogin()
This function returns the lightest loaded login thread. Any thread with a connection count of 0 is used, else the thread with the lowest number of connections.
Returns:
LoginThread found.

setType

public void setType(int type)
Sets the type of listener this is.
Parameters:
type - int type of listener. This must match the type constants specified in the ListenerThread class.

getType

public int getType()
Returns the type of listener this is.
Returns:
int type of listener. This must match the type constants specified in the ListenerThread class.


Copyright © 2002 Clearfield Research Ltd. All Rights Reserved.