OSDN Git Service

Initial commit
[ultramonkey-l7/l7gui.git] / src / src / org / ultramonkey / l7 / controller / EndPoint.java
1 package org.ultramonkey.l7.controller;
2
3 import java.io.Serializable;
4
5 import org.apache.log4j.Logger;
6 import org.ultramonkey.l7.model.LogCategorySet;
7
8 /**
9  * 
10  * <p>
11  * class EndPoint
12  * </p>
13  * <p>
14  * Copyright(c) NTT COMWARE 2008
15  * </p>
16  * 
17  * @author tanuma
18  */
19 public class EndPoint implements Serializable {
20         static final long serialVersionUID = 1L;
21
22         /**
23          * IP address
24          */
25         public String host;
26
27         /**
28          * Port number
29          */
30         public String port;
31
32         /**
33          * Weight
34          */
35         public int weight;
36
37         /**
38          * Active connections
39          */
40         public long actConn;
41
42         /**
43          * Inactive connections
44          */
45         public long inActConn;
46
47         /**
48          * 
49          * Constructor
50          * 
51          */
52         public EndPoint() {
53         // --- debug log (constructor) ---
54                 Logger vsLogger = Logger.getLogger(LogCategorySet.GUI_VIRTUALSERVICE);
55         if (vsLogger.isDebugEnabled()) {
56             vsLogger.debug("11513 class EndPoint created.");
57         }
58         // --- debug log (constructor) ---
59
60                 host = "";
61                 port = "";
62                 weight = 0;
63                 actConn = 0;
64                 inActConn = 0;
65         }
66
67         /**
68          * 
69          * Constructor for real server
70          * 
71          * @param host
72          * @param port
73          * @param weight
74          * @param actConn
75          * @param inActConn
76          */
77         public EndPoint(String host, String port, int weight, long actConn,
78                         long inActConn) {
79         // --- debug log (constructor) ---
80                 Logger vsLogger = Logger.getLogger(LogCategorySet.GUI_VIRTUALSERVICE);
81         if (vsLogger.isDebugEnabled()) {
82             vsLogger.debug("11514 class EndPoint created.");
83         }
84         // --- debug log (constructor) ---
85
86         if (host == null)
87                         this.host = "";
88                 else
89                         this.host = new String(host);
90                 if (port == null)
91                         this.port = "";
92                 else
93                         this.port = new String(port);
94                 this.weight = weight;
95                 this.actConn = actConn;
96                 this.inActConn = inActConn;
97         }
98
99         /**
100          * 
101          * Constructor for virtual service, sorry server
102          * 
103          * @param host
104          * @param port
105          */
106         public EndPoint(String host, String port) {
107         // --- debug log (constructor) ---
108                 Logger vsLogger = Logger.getLogger(LogCategorySet.GUI_VIRTUALSERVICE);
109         if (vsLogger.isDebugEnabled()) {
110             vsLogger.debug("11515 class EndPoint created.");
111         }
112         // --- debug log (constructor) ---
113
114         if (host == null)
115                         this.host = "";
116                 else
117                         this.host = new String(host);
118                 if (port == null)
119                         this.port = "";
120                 else
121                         this.port = new String(port);
122                 this.weight = 0;
123                 this.actConn = 0;
124                 this.inActConn = 0;
125         }
126
127         /**
128          * 
129          * Copy Constructor
130          * 
131          * @param e
132          */
133         public EndPoint(EndPoint e) {
134         // --- debug log (constructor) ---
135                 Logger vsLogger = Logger.getLogger(LogCategorySet.GUI_VIRTUALSERVICE);
136         if (vsLogger.isDebugEnabled()) {
137             vsLogger.debug("11516 class EndPoint created.");
138         }
139         // --- debug log (constructor) ---
140
141         if (e == null) {
142                         host = "";
143                         port = "";
144                         weight = 0;
145                         actConn = 0;
146                         inActConn = 0;
147                 } else {
148                         if (e.host != null)
149                                 this.host = new String(e.host);
150                         if (e.port != null)
151                                 this.port = new String(e.port);
152                         this.weight = e.weight;
153                         this.actConn = e.actConn;
154                         this.inActConn = e.inActConn;
155                 }
156         }
157
158         /**
159          * 
160          * <p>
161          * equals method
162          * </p>
163          * 
164          * @param e
165          * @return
166          */
167         public boolean equals(EndPoint e) {
168         // --- debug log (in method) ---
169                 Logger vsLogger = Logger.getLogger(LogCategorySet.GUI_VIRTUALSERVICE);
170         if (vsLogger.isDebugEnabled()) {
171             vsLogger.debug("11517 EndPoint::equals(EndPoint e) in e=(" + e + ")");
172         }
173         // --- debug log (in method) ---
174
175                 if (e != null && this.host.equals(e.host) && this.port.equals(e.port)) {
176                 // --- debug log (out method) ---
177                 if (vsLogger.isDebugEnabled()) {
178                     vsLogger.debug("11518 EndPoint::equals(EndPoint e) out return=true");
179                 }
180                 // --- debug log (out method) ---
181                         return true;
182                 }
183
184         // --- debug log (out method) ---
185         if (vsLogger.isDebugEnabled()) {
186             vsLogger.debug("11519 EndPoint::equals(EndPoint e) out return=false");
187         }
188         // --- debug log (out method) ---
189                 return false;
190         }
191         
192         /**
193          * 
194          * {@inheritDoc}
195          */
196         public String toString() {
197                 return
198                         "host=\"" + host + "\", " +
199                         "port=\"" + port + "\", " +
200                         "weight=" + weight + ", " +
201                         "actConn=" + actConn + ", " +
202                         "inActConn=" + inActConn;
203         }
204 }