a46aee82e286d56d20b84195ce2fadd4a3135b35
[openflowplugin.git] / test-common / src / main / java / org / opendaylight / openflowplugin / testcommon / DropTestStats.java
1 package org.opendaylight.openflowplugin.testcommon;
2
3 public class DropTestStats {
4     private final int rcvd;
5     private final int sent;
6     private final int excs;
7     private volatile int ftrSuccess;
8     protected volatile int ftrFailed;
9     private final int runablesExecuted;
10     private final int runablesRejected;
11
12     private final String message;
13
14     public DropTestStats(int sent, int rcvd) {
15         this.sent = sent;
16         this.rcvd = rcvd;
17         this.excs = 0;
18         this.runablesExecuted = 0;
19         this.message = null;
20         runablesRejected = 0;
21     }
22
23     public DropTestStats(int sent, int rcvd, int excs) {
24         this.sent = sent;
25         this.rcvd = rcvd;
26         this.excs = excs;
27         this.message = null;
28         this.runablesExecuted = 0;
29         runablesRejected = 0;
30     }
31
32     public DropTestStats(int sent, int rcvd, int excs, int ftrFailed, int ftrSuccess, int runablesExecuted, int runablesRejected) {
33         this.sent = sent;
34         this.rcvd = rcvd;
35         this.excs = excs;
36         this.ftrFailed = ftrFailed;
37         this.ftrSuccess = ftrSuccess;
38         this.message = null;
39         this.runablesExecuted = runablesExecuted;
40         this.runablesRejected = runablesRejected;
41     }
42
43     public DropTestStats(String message) {
44         this.sent = -1;
45         this.rcvd = -1;
46         this.excs = -1;
47         this.message = message;
48         this.runablesExecuted = -1;
49         runablesRejected = 0;
50     }
51
52     public int getSent() {
53         return this.sent;
54     }
55
56     public int getRcvd() {
57         return this.rcvd;
58     }
59
60     public String getMessage() {
61         return this.message;
62     }
63
64     @Override
65     public String toString() {
66         StringBuilder result = new StringBuilder();
67         if (this.message == null) {
68             result.append("\n Rcvd:");
69             result.append(this.rcvd);
70             result.append("\n Sent: ");
71             result.append(this.sent);
72             result.append("\n Exceptions: ");
73             result.append(this.excs);
74
75             result.append("\n future success :");
76             result.append(this.ftrSuccess);
77             result.append("\n future failed :");
78             result.append(this.ftrFailed);
79             result.append("\n run() executions :");
80             result.append(this.runablesExecuted);
81             result.append("\n run() rejected :");
82             result.append(this.runablesRejected);
83
84         } else {
85             result.append(this.message);
86         }
87
88         return result.toString();
89     }
90
91 }