-
Notifications
You must be signed in to change notification settings - Fork 0
/
NetworkStatus.java
47 lines (43 loc) · 1.68 KB
/
NetworkStatus.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* Small class to keep track of information on the network.
*/
public class NetworkStatus {
private int agents = 0;
private int requests = 0;
private int failedRequests = 0;
private int actions = 0;
private int resentRequests = 0;
private int responses = 0;
private int responseTime = 0;
private int activeResponses;
public NetworkStatus(int activeResponses){
this.activeResponses=activeResponses;
}
/**
* increases specified counter by one.
*/
public void incrementAgents(){agents++;}
public void incrementRequests(){requests++;}
public void incrementFailedRequests(){failedRequests++;}
public void incrementActions(){actions++;}
public void incrementResentRequests(){resentRequests++;}
public void incrementResponse(){responses++;}
public void incrementTotalResponseTime(int time){
responseTime=responseTime+time;
}
public void printNetworkStatus(){
System.out.println("\n\n---------------NETWORK SUMMARY---------------");
System.out.println("Actions sent: " + actions);
System.out.println("Agents sent: " + agents);
System.out.println("Requests sent: " + requests);
System.out.println("Requests resent: " + resentRequests);
System.out.println("Requests failed: " + failedRequests);
System.out.println("Requests active at end of program: "
+activeResponses);
System.out.println("Responses received: " + responses);
if(responses!=0)
System.out.println("Average Response time: "
+ (responseTime/responses));
System.out.println("---------------------------------------------");
}
}