|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcz.zcu.fav.kiv.cs.CSServer
This class represents the main server. Every submodel connects to him.
| Field Summary | |
private java.util.LinkedList |
cache
Only for filling the distance matrix. |
private int |
counterForTime
Counter of processes waiting for safe time from server. |
private int |
counterOfFinished
Counter of finished processes. |
private int |
counterOfProc
Counter of connected processes. |
private int |
counterOfWaiting
Counter of processes waiting for others before the next step of the distributed simulation. |
private double[][] |
distanceMatrix
Distance matrix with shortest paths between processes. |
private boolean |
distReceived
True if server has received all distances between neighbours from all processes. |
static int |
numberOfProc
The number of all CSProcesses in the distributed simulation. |
static int |
numberOfSimul
The number of all simulation submodels in the distributed simulation. |
private java.io.PrintWriter[] |
outs
Array of output channels to submodels. |
private int[][] |
procIdentity
Only for first calculating of distance matrix. |
private java.util.HashMap |
procInfo
Knows which process (in what submodel with what ID) represents the ID assigned by user. |
private double[][] |
safeTimes
Matrix with safe times from submodels for other submodels. |
private java.net.ServerSocket |
server
Describes the server socket. |
private long |
start
This is the time, when all submodels have started to simulate. |
static double |
timeWindow
No submodel can advance its local simulation time more than this value ahead of another process. |
private java.util.LinkedList |
waitingForOthers
List of processes waiting for others before the next step of the distributed simulation. |
private java.util.LinkedList |
waitingForTime
List of processes waiting for safe time from server. |
| Constructor Summary | |
CSServer(int port)
Creates the server and connects him to the specified port. |
|
| Method Summary | |
(package private) void |
cacheAdd(java.lang.String line)
Adds a message with distances from a process to the cache. |
(package private) void |
calculateMatrix()
Uses Floyd's algorithm to recalculate distance matrix to set shortest paths between processes. |
(package private) void |
fillMatrix()
Fills in the distance matrix. |
(package private) int |
getIDForCSProc()
Returns an unique ID for process for distance matrix. |
(package private) java.io.PrintWriter[] |
getOuts()
Returns an array of output channels to submodels. |
(package private) CSServerProcInfo |
getProcInfo(int ID)
Return info about specified process. |
(package private) void |
incCounterForTime(int ID)
Increments counter of processes waiting for safe time from server. |
(package private) void |
incCounterOfFinished()
Increments counter of finished processes and carries out related actions to that. |
(package private) void |
incCounterOfWaiting(int ID)
Increments counter of processes waiting for others before the next step of the distributed simulation. |
private void |
listenSocket()
Listens the socket and creates thread for every connected submodel. |
static void |
main(java.lang.String[] args)
The main method. |
private void |
printElementOfMatrix(double element)
Prints element of the distance matrix. |
(package private) void |
printMatrix()
Prints the distance matrix. |
(package private) void |
procInfoPut(int pID,
int simID,
int autoID,
int CSID)
Puts information about IDs of a process into appropriate fields. |
(package private) void |
sendDistances()
Sends an appropriate part of distance matrix to all submodels. |
(package private) void |
sendERROR(int ID)
Sends Error message to all submodels, informing them about falling down of a specified submodel and carries out appropriate actions related to that error. |
private void |
sendSafeTime()
Sends the appropriate safe time for every submodel. |
private void |
sendWaiting()
Sends message to all waiting submodels, informing them, they can continue in the computation. |
(package private) void |
setSafeT(int m,
int n,
double value)
Adds an element to the matrix with safe times. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static int numberOfProc
public static int numberOfSimul
public static double timeWindow
private java.net.ServerSocket server
private java.io.PrintWriter[] outs
private double[][] safeTimes
private double[][] distanceMatrix
private int[][] procIdentity
private java.util.HashMap procInfo
private java.util.LinkedList cache
private java.util.LinkedList waitingForOthers
private java.util.LinkedList waitingForTime
private int counterOfWaiting
private int counterForTime
private int counterOfFinished
private int counterOfProc
private boolean distReceived
private long start
| Constructor Detail |
public CSServer(int port)
throws java.io.IOException
port - int Requested port.| Method Detail |
private final void listenSocket()
throws java.io.IOException
java.io.IOExceptionprivate final void sendWaiting()
final void sendERROR(int ID)
ID - int ID of broken submodel.final void sendDistances()
private final void sendSafeTime()
final void printMatrix()
private final void printElementOfMatrix(double element)
final void fillMatrix()
final void calculateMatrix()
final void incCounterOfFinished()
final void incCounterForTime(int ID)
final void incCounterOfWaiting(int ID)
final void cacheAdd(java.lang.String line)
final void setSafeT(int m,
int n,
double value)
m - int Row - From Whomn - int Column - For Whomvalue - double Safe time
final void procInfoPut(int pID,
int simID,
int autoID,
int CSID)
pID - int ID of process assigned by user.simID - int ID of submodel, where is the process located.autoID - int ID of process assigned by submodel.CSID - int ID of process for distance matrix assigned by server.final CSServerProcInfo getProcInfo(int ID)
ID - int ID assigned by user of requested process.
final java.io.PrintWriter[] getOuts()
final int getIDForCSProc()
public static void main(java.lang.String[] args)
args - String[] Should be: port, number of processes, number of submodels and time window.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||