| java.lang.Object org.datashare.DataShareServer
DataShareServer | public class DataShareServer implements DataReceiverInterface,TreeViewServerInterface,FifoConsumer(Code) | | For now, a limitation of this design is that it uses a separate port for each Session and Channel.
This will be changed in the future so that better 'in band' information will let a single server port
serve more that one purpose. Trying to keep it simple for now.
author: Charles Wood version: 1.0 |
Method Summary | |
public ServerInfo | addClient(RegistrationInfo ri, SocketAdapter ts) Takes client username, makes it unique, puts client's unique name into our
Hashtable of clients, keeps a copy of what machine IP they registered from,
and sends back to the client information about their unique name and server info. | public void | addConsumer(String clientKey, String sessionKey, String channelKey, boolean channelActive) Called when a new consumer had been detected on a ThreadedServer socket (this is called
from DataReceiverAdapter instances via the TreeViewServerInterface), puts the consumer in
the list of consumers for the channel, notifies all registered clients, and creates the
consumer EJB if not already created. | public void | clientDataReceived(DataShareObject dsObject, SocketAdapter ts) All DataShare connections require that the user 'register' on the channel before it
will be made 'active' by the server. | public void | connectionLost(SocketAdapter ts) | public ClientSessionInfo | createSession(SocketAdapter ts, CreateSessionRequest csr) Used to create a Session that contains the Channels described by the CreateSessionRequest object. | void | deleteEmptySessions() this method will delete any sessions that do not have saved data. | public ClientInfo | getClientInfo(String clientKey) | public synchronized int | getNextPort() used to provide the next port number to use for a Channel connection. | public boolean | getPersistData() | public PersistenceInterface | getPersistenceInterface() | public String | getServerInfo() | public Hashtable | getSessionTable() | public boolean | getShowArchivedSessionsToAdmin() | public Hashtable | getSpecialClientTable() | public void | initialize() | void | initializeValues(String args) | public boolean | isClientAdmin(String clientKey) | public boolean | isClientRegistered(String clientKey) | public void | lostServerSocket(String keyValue) This is called when we lose our serverSocket, we can no longer make new connections,
and may have lost the ability to use old ones for this socket. | public static void | main(String args) | public void | newConnection(SocketAdapter ts) called when someone new connects to our commandStatus Connection. | public void | newFifoDataAvailable(Object obj) called from the Fifo thread when data is available in the FIFO. | public void | removeAndDisconnectConsumer(String clientKey, String sessionKey, String channelKey) Called when a consumer closes a Channel connection for which the server cannot
detect that the connection is closed (i.e. | public void | removeClient(String clientKeyValue) removes all references to a Client, takes care of closing its connections and
notifying other Clients. | public void | removeConsumer(String clientKey, String sessionKey, String channelKey) | public void | saveDataToDatabase(String tableName, Hashtable props, PersistDataCallbackInterface callback) This method saveds the specified data to the database and puts the data's key value into the
PersistDataCallbackInterface instance after the data is created. | public void | shutDownConnectionsAndThreads() called when we need to shutdown all client connections and threads (i.e. |
TCPSocketReadTimeout | static int TCPSocketReadTimeout(Code) | | |
currentPort | static int currentPort(Code) | | |
dataLoopFinished | boolean dataLoopFinished(Code) | | |
logInAdapterFound | static boolean logInAdapterFound(Code) | | |
logInInterfaceClassName | static String logInInterfaceClassName(Code) | | |
loggingInterfaceClassName | static String loggingInterfaceClassName(Code) | | |
objectCount | static int objectCount(Code) | | |
persistData | protected static boolean persistData(Code) | | true if we will be using a database to save info about DataShare objects. Must be false
if useDatabase is false. Note that individual channels have their own control over saving data.
This value is set at startup and must not change. Cannot be true if useDatabase is false. If useDatabase
is true and this is false, then information about Clients and Sessions (and their associated info) will
not be saved. This can be initialized as a command line parameter.
|
persistenceAdapterFound | static boolean persistenceAdapterFound(Code) | | |
persistenceInterfaceClassName | static String persistenceInterfaceClassName(Code) | | |
properties | static Hashtable properties(Code) | | this is where we will store our configurable data, can be overwritten by
Java defines. May also be overwritten by command line options. Normal
SystemProperties may be added into this if a propertiesManager is loaded.
|
propertiesInterfaceClassName | static String propertiesInterfaceClassName(Code) | | |
serviceAdapterFound | static boolean serviceAdapterFound(Code) | | |
serviceInterfaceClassName | static String serviceInterfaceClassName(Code) | | |
showArchivedSessionsToAdmin | static boolean showArchivedSessionsToAdmin(Code) | | |
waitingForTokens | List waitingForTokens(Code) | | if a client has to wait for a token, their request goes into this item.
want to use linked list so we can better manage taking items out of the
middle and append to the end.
|
DataShareServer | public DataShareServer()(Code) | | Constructor, creates our DataShare server
|
addClient | public ServerInfo addClient(RegistrationInfo ri, SocketAdapter ts)(Code) | | Takes client username, makes it unique, puts client's unique name into our
Hashtable of clients, keeps a copy of what machine IP they registered from,
and sends back to the client information about their unique name and server info.
Note that all clients must have unique clientKey, even clients of dissimilar classes/types
|
addConsumer | public void addConsumer(String clientKey, String sessionKey, String channelKey, boolean channelActive)(Code) | | Called when a new consumer had been detected on a ThreadedServer socket (this is called
from DataReceiverAdapter instances via the TreeViewServerInterface), puts the consumer in
the list of consumers for the channel, notifies all registered clients, and creates the
consumer EJB if not already created.
|
clientDataReceived | public void clientDataReceived(DataShareObject dsObject, SocketAdapter ts)(Code) | | All DataShare connections require that the user 'register' on the channel before it
will be made 'active' by the server. this is so the server can associate a unique client
name with each socket. The client must register with the server before it will
be added as a Client that other Clients can see. The data received here is from the
clients commandStatusConnection channel. Note that when we call ts.sendData() here,
the object sent goes to client the message was received from only. Also note that
calls to this method come from the Thread of the Socket from which the data was received.
|
connectionLost | public void connectionLost(SocketAdapter ts)(Code) | | This is called when we lose a client's commandStatus connection to our server
|
deleteEmptySessions | void deleteEmptySessions()(Code) | | this method will delete any sessions that do not have saved data. If data
is not being saved (i.e. no database, etc.), no action is taken. This method
should not be called if there are active consumers in any of the channels as it
will not gracefully remove them (call shutdownConnectionsAndThreads first). Also
note that this method will not clean up the sessionTable by removing the sessions
whose data has been deleted. This method is designed to be called at shutdown to
clean up the database prior to the next startup of the DataShare server.
|
getClientInfo | public ClientInfo getClientInfo(String clientKey)(Code) | | Returns the ClientInfo for this client is this client is found in specialClients table,
or null if not found
|
getNextPort | public synchronized int getNextPort()(Code) | | used to provide the next port number to use for a Channel connection. Currently, no distinction
is made between a UDP and a TCP connection (we could have UDP and TCP use the same port for
different sockets).
|
getPersistData | public boolean getPersistData()(Code) | | Used to determine if this server instance supports persisting data
true if server supports persisting data, false otherwise |
getPersistenceInterface | public PersistenceInterface getPersistenceInterface()(Code) | | returns reference to persistence interface, should be non-null if getPersistData() returns true,
may be null otherwise
|
getSessionTable | public Hashtable getSessionTable()(Code) | | returns the table of sessions
|
getShowArchivedSessionsToAdmin | public boolean getShowArchivedSessionsToAdmin()(Code) | | |
getSpecialClientTable | public Hashtable getSpecialClientTable()(Code) | | returns the table of clients
|
initialize | public void initialize()(Code) | | Creates the CommandStatus Channel for communicating with Clients
|
initializeValues | void initializeValues(String args)(Code) | | give default values to properties
|
isClientAdmin | public boolean isClientAdmin(String clientKey)(Code) | | Parameters: clientKey - keyValue of client to be checked for Admin privileges true if client has Admin privileges, false otherwise |
isClientRegistered | public boolean isClientRegistered(String clientKey)(Code) | | Returns true if this client is in the list of clients who have registered, false otherwise
|
lostServerSocket | public void lostServerSocket(String keyValue)(Code) | | This is called when we lose our serverSocket, we can no longer make new connections,
and may have lost the ability to use old ones for this socket. This particular serverSocket
is the overall commandStatusPort connection socket.
|
newConnection | public void newConnection(SocketAdapter ts)(Code) | | called when someone new connects to our commandStatus Connection.
At this point, we know IP and port, but not who is using it.
ThreadedSocket is saved in Hashtable keyed by clientKey (unique Client name)
|
newFifoDataAvailable | public void newFifoDataAvailable(Object obj)(Code) | | called from the Fifo thread when data is available in the FIFO. Data was put into
the FIFO by the persistDataQueue.write() method. This is called when the Fifo thread has
finished with waiting for the previous database key to be created?
|
removeAndDisconnectConsumer | public void removeAndDisconnectConsumer(String clientKey, String sessionKey, String channelKey)(Code) | | Called when a consumer closes a Channel connection for which the server cannot
detect that the connection is closed (i.e. UDP), this will remove the consumer from
our tables, our tree, and cause the connection to close for that client in that channel
|
removeClient | public void removeClient(String clientKeyValue)(Code) | | removes all references to a Client, takes care of closing its connections and
notifying other Clients.
|
removeConsumer | public void removeConsumer(String clientKey, String sessionKey, String channelKey)(Code) | | Called when a consumer had closed a Channel connection (this is called
from DataReceiverAdapter instances via the TreeViewServerInterface)
|
saveDataToDatabase | public void saveDataToDatabase(String tableName, Hashtable props, PersistDataCallbackInterface callback)(Code) | | This method saveds the specified data to the database and puts the data's key value into the
PersistDataCallbackInterface instance after the data is created.
Parameters: tableName - the name of the table this data should be added to Parameters: props - describes what is to be persisted in the database Parameters: callback - the interface that supplies the methods used to set the Key for this data |
shutDownConnectionsAndThreads | public void shutDownConnectionsAndThreads()(Code) | | called when we need to shutdown all client connections and threads (i.e. we are exiting)
|
|
|