Class ServerData

java.lang.Object
  extended byServerData

public class ServerData
extends java.lang.Object

This class contain all buffer a shared fields
there are methods for access to variables


Field Summary
 boolean am_all
           
 java.util.ArrayList am_queue
           
 ServerUserItem[] base
           
 int c_count
           
static int C_LEVEL
           
 long deadlockIdleTime
           
 long endSimTime
           
 java.io.FileWriter fw
           
 boolean go_all
           
 java.util.ArrayList list_not_users
           
 boolean printOnScreen
           
 boolean printToFile
           
 java.util.ArrayList queue
           
 long startSimTime
           
 boolean stop_all
           
 
Constructor Summary
ServerData(ServerGui par_gui)
          Constructor of class stack_data
 
Method Summary
 void addNotReadyUser(java.lang.String ParUserName)
          Add user to list of not yet ready users

PAR : (String) .. user name
 int addSender(int ParClientId, java.lang.String ParSenderName)
          This method add sender name to stack

PAR: (int) ..client ID
(String) ..sender name

RV: (int) 1.. sucess
-1.. item allready exist
 int allClientsGoAck()
          All clients send order go_ack

RV: (int) 1 .. yes
-1 .. no
 int allClientsReady()
          Are all clients ready?
 int allClientsSimOver()
          all simulation over

RV: (int) 1 .. yes
-1 .. no
 int allClientsStopAck()
          All clients send order stop_ack

RV: (int) 1 .. yes
-1 .. no
 void allFlagsSet()
          seting all flag involved to stop&go simulation
 boolean anyMessageNotSended(java.lang.String ParName)
          Are in queue any messages for user

Par: (String) ParName .. receiver name
RV : true .. yes in stack is message for u.
 int closeTraficFile()
          Close server login file

RV: (int) 1 .. file closed succefully
-1 ..
 void dropTable()
          Print list of all clients and his status
 int eraseAMFromQueue(double ParMessage)
          Erase item from Anti-Message queue

PAR: (double) ParMessage .. time stamp of anti-m.
 int eraseMessageWhenRollback(double ParTimeStamp, java.lang.String ParReceiverName)
          This method delete all message in stack when
anti-message comin

PAR: (double) .. anti message time stamp
(string) .. receiver name

RV: (int) .. count of deleted messages
 ServerMessageItem get(int par_id)
          Get the message with lowest time_stamp from shared server's memory

PAR : (int) par_id .. reveiver id

RETURN VALUE : (server_message_item)
or null if something wrong

 int getCountOfEvents(int ParUserId)
          This method return count of events for user

PAR: (int) .. user id

RV: (int) .. count of events in stack
 double getGVT()
          This method comput GTV

RV: (double) value of GVT
 long getServerIdle()
          This method get time how long is server
not working

RV(long) .. time in milisekunds
 int getUserId(java.lang.String par_user_name)
          This method return ID of user

PAR : (String) user name

Return Value: (int) user ID from variable base
-1 user not found

 int checkAllSenderLastEvent(int ParClientId)
          This method check if all simulation of sender
are done
PAR: (int) ..client ID

RV: (int) 0 ..
 int isUserInReadyList(java.lang.String par_name)
          Is this user in ready list ?
 ServerMessageItem loadFromAMQueue(int ParId)
          Load message with lowest time stamp from queue

Par: (int) ParId .. receiver id

RV: (MessageItem) .. message

 int put(ServerMessageItem par_item, int par_id)
          storing message to stack and inc message counter

par_item contain flag of message, sender name, message, receiver name

Return Value : (int)

1 .. saved sucesfully
 int setSenderLastEvent(int ParId, boolean ParSimDone)
          This method set that sender simulation is done

PAR:(int) ..
 int storeClient(int par_id, java.lang.String par_name)
          store user to ready-user list
if user is in not-ready-user list his item
is erased

PAR: (int) par_id .. user id
(String) par_name .. user name

RV: (int)
 void storeToAMQueue(int ParFlag, java.lang.String ParFrom, java.lang.String ParTo, double ParMessage1, double ParMessage2, int ParGate)
          Store parts of anti message to Buffer

PAR: (int) ParFlag .. kind of meesage
(String) ParFrom .. message sender
(String) ParTo .. message receiver
(double) ParMessage1 .. time stamp 1
(double) ParMessage2 .. time stamp 2

 void unlock()
          Unlock all users
 void writeToFile(java.lang.String ParLine)
          Write to server login file or on screen

Par: (String) ParLine ..
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

C_LEVEL

public static final int C_LEVEL
See Also:
Constant Field Values

c_count

public int c_count

base

public ServerUserItem[] base

stop_all

public boolean stop_all

am_all

public boolean am_all

go_all

public boolean go_all

fw

public java.io.FileWriter fw

list_not_users

public java.util.ArrayList list_not_users

queue

public java.util.ArrayList queue

am_queue

public java.util.ArrayList am_queue

startSimTime

public long startSimTime

endSimTime

public long endSimTime

printOnScreen

public boolean printOnScreen

printToFile

public boolean printToFile

deadlockIdleTime

public long deadlockIdleTime
Constructor Detail

ServerData

public ServerData(ServerGui par_gui)
Constructor of class stack_data

Method Detail

getServerIdle

public long getServerIdle()
This method get time how long is server
not working

RV(long) .. time in milisekunds


getCountOfEvents

public int getCountOfEvents(int ParUserId)
This method return count of events for user

PAR: (int) .. user id

RV: (int) .. count of events in stack


getGVT

public double getGVT()
This method comput GTV

RV: (double) value of GVT


eraseMessageWhenRollback

public int eraseMessageWhenRollback(double ParTimeStamp,
                                    java.lang.String ParReceiverName)
This method delete all message in stack when
anti-message comin

PAR: (double) .. anti message time stamp
(string) .. receiver name

RV: (int) .. count of deleted messages


addSender

public int addSender(int ParClientId,
                     java.lang.String ParSenderName)
This method add sender name to stack

PAR: (int) ..client ID
(String) ..sender name

RV: (int) 1.. sucess
-1.. item allready exist


setSenderLastEvent

public int setSenderLastEvent(int ParId,
                              boolean ParSimDone)
This method set that sender simulation is done

PAR:(int) .. id name
(boolean) .. done - true

RV: (int) 1.. sucess
-1.. item not exist


checkAllSenderLastEvent

public int checkAllSenderLastEvent(int ParClientId)
This method check if all simulation of sender
are done
PAR: (int) ..client ID

RV: (int) 0 .. not ready yet
1 .. yes you can send Last Time
2 .. yes you must send Last Time
deadlock situation occur


closeTraficFile

public int closeTraficFile()
Close server login file

RV: (int) 1 .. file closed succefully
-1 .. can't close file


writeToFile

public void writeToFile(java.lang.String ParLine)
Write to server login file or on screen

Par: (String) ParLine .. Input text


storeToAMQueue

public void storeToAMQueue(int ParFlag,
                           java.lang.String ParFrom,
                           java.lang.String ParTo,
                           double ParMessage1,
                           double ParMessage2,
                           int ParGate)
Store parts of anti message to Buffer

PAR: (int) ParFlag .. kind of meesage
(String) ParFrom .. message sender
(String) ParTo .. message receiver
(double) ParMessage1 .. time stamp 1
(double) ParMessage2 .. time stamp 2


eraseAMFromQueue

public int eraseAMFromQueue(double ParMessage)
Erase item from Anti-Message queue

PAR: (double) ParMessage .. time stamp of anti-m.

RV: (Inr) 1 .. antimessage erased succefully
-1 .. can't find antimessage


loadFromAMQueue

public ServerMessageItem loadFromAMQueue(int ParId)
Load message with lowest time stamp from queue

Par: (int) ParId .. receiver id

RV: (MessageItem) .. message


anyMessageNotSended

public boolean anyMessageNotSended(java.lang.String ParName)
Are in queue any messages for user

Par: (String) ParName .. receiver name
RV : true .. yes in stack is message for u.
false .. no isn't


addNotReadyUser

public void addNotReadyUser(java.lang.String ParUserName)
Add user to list of not yet ready users

PAR : (String) .. user name


isUserInReadyList

public int isUserInReadyList(java.lang.String par_name)
Is this user in ready list ?

PAR (String) par_name .. user name
RV: (int)
1 .. yes
-1 .. no


allClientsStopAck

public int allClientsStopAck()
All clients send order stop_ack

RV: (int) 1 .. yes
-1 .. no


allClientsSimOver

public int allClientsSimOver()
all simulation over

RV: (int) 1 .. yes
-1 .. no


allClientsGoAck

public int allClientsGoAck()
All clients send order go_ack

RV: (int) 1 .. yes
-1 .. no


allFlagsSet

public void allFlagsSet()
seting all flag involved to stop&go simulation


allClientsReady

public int allClientsReady()
Are all clients ready?

RV: (int) 1 .. all ready
-1 .. no


getUserId

public int getUserId(java.lang.String par_user_name)
This method return ID of user

PAR : (String) user name

Return Value: (int) user ID from variable base
-1 user not found


storeClient

public int storeClient(int par_id,
                       java.lang.String par_name)
store user to ready-user list
if user is in not-ready-user list his item
is erased

PAR: (int) par_id .. user id
(String) par_name .. user name

RV: (int)


dropTable

public void dropTable()
Print list of all clients and his status


unlock

public void unlock()
Unlock all users


get

public ServerMessageItem get(int par_id)
Get the message with lowest time_stamp from shared server's memory

PAR : (int) par_id .. reveiver id

RETURN VALUE : (server_message_item)
or null if something wrong


put

public int put(ServerMessageItem par_item,
               int par_id)
storing message to stack and inc message counter

par_item contain flag of message, sender name, message, receiver name

Return Value : (int)

1 .. saved sucesfully