synapsi.main
Class NeuronServer


java.lang.Object

  |

  +--synapsi.main.NeuronServer


public class NeuronServer
extends java.lang.Object
implements MainForGui, MainForNet

Main thread of the Neuron server - handles information passing between different components of Neuron server (GUI, data bank, network part). Methods inherited from synapsi.main.MainForGui, and synapsi.main.MainForNet are not documented here - the documentation can be view from the corresponding interface documentation.


Field Summary
static int ERR_DATA_MODULE_INIT
          Error code: Data module cannot be initialized.
static int ERR_DATA_MODULE_SAVE
          Error code: Data module cannot be saved.
static int ERR_DEFAULT_GROUP_REMOVAL
          Error code: Default group cannot be removed.
static int ERR_GROUP_HAS_CLIENTS
          Error code: Group cannot be removed - it contains clients.
static int ERR_ILLEGAL_CLIENT
          Error code: Not a valid client
static int ERR_ILLEGAL_GROUP_NAME
          Error code: Group name already in used by some group.
static int ERR_ILLEGAL_PACKAGE
          Error code: There is something wrong in the package
static int ERR_PACKAGE_ALREADY_INSTALLED
          Error code: Package cannot be installed - it is already installed in the system.
static int ERR_PACKAGE_STILL_IN_USE
          Error code: Package cannot be removed - it is used by some group.
static int ERR_SOME_PARAMS_ARE_NULL_OR_ILLEGAL
          Error code: Some method call has delivered invalid parameters (=programming error)
static int ERR_UNSPECIFIED
          Error code: This is to be used only when something realy weird happens
protected static java.lang.String Name
           
static int OK
          Error code: Group name already in used by some group.
 
Constructor Summary
NeuronServer()
          Costructor of the class - creates a new NeuronServer object.
 
Method Summary
 int addClientToGroup(java.lang.String clientIP, java.lang.String groupID)
          Adds a new client to the specified group.
 int addGroup(java.lang.String groupID, java.lang.String version)
          Adds a new group to the system.
 int addNewPackage(java.lang.String pathToFiles, java.lang.String id, java.lang.String version, java.lang.String os, byte[] MD5)
          Adds new software package to server.
 void ClientActivate(java.lang.String IP)
          Tell NS that client is active.
 void ClientDeactivate(java.lang.String IP)
          Tell NS that client is not active.
 DataVersion getClientVersion(java.lang.String clientIP)
          Returns the version of client's software package.
 java.util.Vector getGroupClients(java.lang.String groupID)
          Returns the clients (client IP, version and current status) of the specified group.
 java.util.Vector getGroups()
          Returns all groups in the system.
 DataVersion getGroupVersion(java.lang.String groupID)
          Returns the software version currently assigned to the specified group.
 int getNSSettings()
          Retrieves the number of conncurrent clients
 java.util.Vector getPackages()
          Returns all the software package IDs currently in the system.
 int init()
          Initialize the data's from disk.
 int init(java.lang.String pathToFile)
          Initialize the data from the disk.
static void main(java.lang.String[] args)
           
 int removeClientFromGroup(java.lang.String clientIP, java.lang.String groupID)
          Removes a client from the specified group.
 int removeGroup(java.lang.String groupID)
          Removes the specified group from the system.
 int removePackage(java.lang.String version)
          Removes an old package from the system.
 int save()
          Saves the data to disk.
 int save(java.lang.String pathToFile)
          Saves the data to the wanted location on the disk.
 int setClientToGroup(java.lang.String clientIP, java.lang.String groupID)
          Set's the client to group
 int setClientVersion(java.lang.String clientIP, byte[] bMD5, java.lang.String version)
          Notifies when a client's version number has changed.
 int setGroupInfo(java.lang.String oldID, java.lang.String newID, java.lang.String version)
          Sets new group ID and/or software version to a group.
 void setNSSettings(int concurrentClients)
          Sets a new value to the number of concurrent clients.
 void TestClientInfo(java.lang.String ip, boolean b)
          Usefull method for testing / debugging purposes Set's the client online / offline
 void threadEnd()
          Decreases number of running threads
 int threadStart(UpdateThread t)
          Increases number of running threads
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Name


protected static final java.lang.String Name

OK


public static final int OK
Error code: Group name already in used by some group.

ERR_DEFAULT_GROUP_REMOVAL


public static final int ERR_DEFAULT_GROUP_REMOVAL
Error code: Default group cannot be removed.

ERR_GROUP_HAS_CLIENTS


public static final int ERR_GROUP_HAS_CLIENTS
Error code: Group cannot be removed - it contains clients.

ERR_PACKAGE_STILL_IN_USE


public static final int ERR_PACKAGE_STILL_IN_USE
Error code: Package cannot be removed - it is used by some group.

ERR_PACKAGE_ALREADY_INSTALLED


public static final int ERR_PACKAGE_ALREADY_INSTALLED
Error code: Package cannot be installed - it is already installed in the system.

ERR_DATA_MODULE_INIT


public static final int ERR_DATA_MODULE_INIT
Error code: Data module cannot be initialized.

ERR_DATA_MODULE_SAVE


public static final int ERR_DATA_MODULE_SAVE
Error code: Data module cannot be saved.

ERR_ILLEGAL_GROUP_NAME


public static final int ERR_ILLEGAL_GROUP_NAME
Error code: Group name already in used by some group.

ERR_ILLEGAL_PACKAGE


public static final int ERR_ILLEGAL_PACKAGE
Error code: There is something wrong in the package

ERR_ILLEGAL_CLIENT


public static final int ERR_ILLEGAL_CLIENT
Error code: Not a valid client

ERR_UNSPECIFIED


public static final int ERR_UNSPECIFIED
Error code: This is to be used only when something realy weird happens

ERR_SOME_PARAMS_ARE_NULL_OR_ILLEGAL


public static final int ERR_SOME_PARAMS_ARE_NULL_OR_ILLEGAL
Error code: Some method call has delivered invalid parameters (=programming error)
Constructor Detail

NeuronServer


public NeuronServer()
Costructor of the class - creates a new NeuronServer object.
Method Detail

threadStart


public int threadStart(UpdateThread t)
Increases number of running threads
Specified by:
threadStart in interface MainForNet
Parameters:
t - The thread that is calling this method.
Returns:
0, if OK, -1, if maximum number of running threads was exceeded

threadEnd


public void threadEnd()
Decreases number of running threads
Specified by:
threadEnd in interface MainForNet

ClientActivate


public void ClientActivate(java.lang.String IP)
Tell NS that client is active. If client exist
Specified by:
ClientActivate in interface MainForNet
Parameters:
IP - IP of new client

ClientDeactivate


public void ClientDeactivate(java.lang.String IP)
Tell NS that client is not active.
Specified by:
ClientDeactivate in interface MainForNet
Parameters:
IP - IP of new client

save


public int save()
Description copied from interface: MainForGui
Saves the data to disk. Uses the default name for file.
Specified by:
save in interface MainForGui
Tags copied from interface: MainForGui
Returns:
0, if save successful.

save


public int save(java.lang.String pathToFile)
Description copied from interface: MainForGui
Saves the data to the wanted location on the disk.
Specified by:
save in interface MainForGui
Tags copied from interface: MainForGui
Parameters:
pathToFile - Location where we wish to save.
Returns:
0, if save successful.

init


public int init()
Description copied from interface: MainForGui
Initialize the data's from disk. Uses the default name for serilized file.
Specified by:
init in interface MainForGui
Tags copied from interface: MainForGui
Returns:
0, if init is successful.

init


public int init(java.lang.String pathToFile)
Description copied from interface: MainForGui
Initialize the data from the disk.
Specified by:
init in interface MainForGui
Tags copied from interface: MainForGui
Parameters:
pathToFile - Path to the file where the data is saved.
Returns:
0, if save successful.

getPackages


public java.util.Vector getPackages()
Description copied from interface: MainForGui
Returns all the software package IDs currently in the system.
Specified by:
getPackages in interface MainForGui
Tags copied from interface: MainForGui
Returns:
A vector of package IDs.

getGroupClients


public java.util.Vector getGroupClients(java.lang.String groupID)
Description copied from interface: MainForGui
Returns the clients (client IP, version and current status) of the specified group.
Specified by:
getGroupClients in interface MainForGui
Tags copied from interface: MainForGui
Parameters:
groupID - The group which is handled.
Returns:
A vector of client information of this group.

getClientVersion


public DataVersion getClientVersion(java.lang.String clientIP)
Description copied from interface: MainForGui
Returns the version of client's software package.
Specified by:
getClientVersion in interface MainForGui
Tags copied from interface: MainForGui
Parameters:
clientIP - The IP of the client to be handled.
Returns:
Version information of this client.

getGroupVersion


public DataVersion getGroupVersion(java.lang.String groupID)
Description copied from interface: MainForGui
Returns the software version currently assigned to the specified group.
Specified by:
getGroupVersion in interface MainForGui
Tags copied from interface: MainForGui
Parameters:
groupID - The ID of the group to be handled.
Returns:
Version information of this group.

getGroups


public java.util.Vector getGroups()
Description copied from interface: MainForGui
Returns all groups in the system.
Specified by:
getGroups in interface MainForGui
Tags copied from interface: MainForGui
Returns:
A vector containing all groups.

setGroupInfo


public int setGroupInfo(java.lang.String oldID,
                        java.lang.String newID,
                        java.lang.String version)
Description copied from interface: MainForGui
Sets new group ID and/or software version to a group.
Specified by:
setGroupInfo in interface MainForGui
Tags copied from interface: MainForGui
Parameters:
oldID - Old group ID of the group.
newID - New group ID for the group (if only software version changed, the same as oldID).
version - New software version to the group.
Returns:
0 if OK else some error code

addGroup


public int addGroup(java.lang.String groupID,
                    java.lang.String version)
Description copied from interface: MainForGui
Adds a new group to the system.
Specified by:
addGroup in interface MainForGui
Tags copied from interface: MainForGui
Parameters:
groupID - The group ID of the new group.
version - Software version to the new group.
Returns:
0 if OK else some error code

removeGroup


public int removeGroup(java.lang.String groupID)
Description copied from interface: MainForGui
Removes the specified group from the system.
Specified by:
removeGroup in interface MainForGui
Tags copied from interface: MainForGui
Parameters:
groupID - The group ID of the group to be removed.
Returns:
0 if OK else some error code

setNSSettings


public void setNSSettings(int concurrentClients)
Description copied from interface: MainForGui
Sets a new value to the number of concurrent clients.
Specified by:
setNSSettings in interface MainForGui
Tags copied from interface: MainForGui
Parameters:
concurrentClients - A new value to the number of concurrent clients.

getNSSettings


public int getNSSettings()
Description copied from interface: MainForGui
Retrieves the number of conncurrent clients
Specified by:
getNSSettings in interface MainForGui
Tags copied from interface: MainForGui
Returns:
the number of clients

addNewPackage


public int addNewPackage(java.lang.String pathToFiles,
                         java.lang.String id,
                         java.lang.String version,
                         java.lang.String os,
                         byte[] MD5)
Description copied from interface: MainForGui
Adds new software package to server. Params need some refinement
Specified by:
addNewPackage in interface MainForGui
Tags copied from interface: MainForGui
Parameters:
pathToFiles - Path to file/files, where the update package is located.
Id - Unique version identification string for this software package
version - The version number
os - The OS this version is inteded
Returns:
none zero error-code if failed

removePackage


public int removePackage(java.lang.String version)
Description copied from interface: MainForGui
Removes an old package from the system.
Specified by:
removePackage in interface MainForGui
Tags copied from interface: MainForGui
Parameters:
version - The version of the package to be removed.
Returns:
none zero error-code if failed

setClientToGroup


public int setClientToGroup(java.lang.String clientIP,
                            java.lang.String groupID)
Description copied from interface: MainForGui
Set's the client to group
Specified by:
setClientToGroup in interface MainForGui
Tags copied from interface: MainForGui
Parameters:
clientIP - Client we are moving
GroupID - The group we are planning to move the client
Returns:
none zero error-code if failed

addClientToGroup


public int addClientToGroup(java.lang.String clientIP,
                            java.lang.String groupID)
Description copied from interface: MainForGui
Adds a new client to the specified group.
Specified by:
addClientToGroup in interface MainForGui
Tags copied from interface: MainForGui
Parameters:
clientIP - The IP of the client to be added.
groupID - The ID of the group where client is added.
Returns:
none zero error-code if failed

removeClientFromGroup


public int removeClientFromGroup(java.lang.String clientIP,
                                 java.lang.String groupID)
Description copied from interface: MainForGui
Removes a client from the specified group.
Specified by:
removeClientFromGroup in interface MainForGui
Tags copied from interface: MainForGui
Parameters:
clientIP - The IP of the client to be removed.
groupID - The ID of the group where client is removed.
Returns:
none zero error-code if failed

setClientVersion


public int setClientVersion(java.lang.String clientIP,
                            byte[] bMD5,
                            java.lang.String version)
Description copied from interface: MainForNet
Notifies when a client's version number has changed.
Specified by:
setClientVersion in interface MainForNet
Tags copied from interface: MainForNet
Parameters:
clientIP - The IP of the client.
MD5 - MD5-sum of clients current version.
version - The new version of the client.
Returns:
0 if successful, else nonzero.

main


public static void main(java.lang.String[] args)

TestClientInfo


public void TestClientInfo(java.lang.String ip,
                           boolean b)
Description copied from interface: MainForGui
Usefull method for testing / debugging purposes Set's the client online / offline
Specified by:
TestClientInfo in interface MainForGui
Tags copied from interface: MainForGui
Parameters:
ip - client's IP which we want to set Online status
b - is the client online or not