Make sure invokeOperation is set once
[controller.git] / opendaylight / adsal / samples / loadbalancer / src / main / java / org / opendaylight / controller / samples / loadbalancer / entities / PoolMember.java
1 /*
2  * Copyright IBM Corporation, 2013.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.samples.loadbalancer.entities;
9
10
11 import javax.xml.bind.annotation.XmlAccessType;
12 import javax.xml.bind.annotation.XmlAccessorType;
13 import javax.xml.bind.annotation.XmlElement;
14 import javax.xml.bind.annotation.XmlRootElement;
15
16 /**
17  * This class represents the host where load balancing service will
18  * redirect VIP traffic for load balancing. All these hosts have to
19  * register with a pool to be a part of traffic load balancing.
20  * This entity is referred to as a 'PoolMember'.
21  * Load balancer service differentiates each pool member based on its
22  * two properties { ip address, attached pool }.
23  * A host (IP) can be attached to two different pools through creation of two
24  * different pool member objects.
25  *
26  * NOTE: Each pool member should have a unique name.
27  *
28  */
29 @XmlRootElement(name="poolmember")
30 @XmlAccessorType(XmlAccessType.NONE)
31 public class PoolMember {
32
33     /*
34      * Unique name of the pool member
35      */
36     @XmlElement
37     private String name;
38
39     /*
40      * IP address of the pool member
41      */
42     @XmlElement
43     private String ip;
44
45     /*
46      * Name of the pool this member is attached to.
47      */
48     @XmlElement(name="poolname")
49     private String poolName;
50
51     /*
52      * Status (active/inactive)
53      */
54     @XmlElement
55     private String status;
56
57     /**
58      * Private constructor used for JAXB mapping
59      */
60     @SuppressWarnings("unused")
61     private PoolMember() {}
62
63     public PoolMember(String name, String memberIP, String poolName){
64         this.name = name;
65         this.ip = memberIP;
66         this.poolName = poolName;
67     }
68
69     /**
70      * @return the name
71      */
72     public String getName() {
73         return name;
74     }
75
76     /**
77      * @param name the name to set
78      */
79     public void setName(String name) {
80         this.name = name;
81     }
82
83     /**
84      * @return the ip
85      */
86     public String getIp() {
87         return ip;
88     }
89
90     /**
91      * @param ip the ip to set
92      */
93     public void setIp(String ip) {
94         this.ip = ip;
95     }
96
97     /**
98      * @return the poolName
99      */
100     public String getPoolName() {
101         return poolName;
102     }
103
104     /**
105      * @param poolName the poolName to set
106      */
107     public void setPoolName(String poolName) {
108         this.poolName = poolName;
109     }
110
111     /**
112      * @return the status
113      */
114     public String getStatus() {
115         return status;
116     }
117
118     /**
119      * @param status the status to set
120      */
121     public void setStatus(String status) {
122         this.status = status;
123     }
124
125     /* (non-Javadoc)
126      * @see java.lang.Object#hashCode()
127      */
128     @Override
129     public int hashCode() {
130         final int prime = 31;
131         int result = 1;
132         result = prime * result + ((ip == null) ? 0 : ip.hashCode());
133         result = prime * result
134                 + ((poolName == null) ? 0 : poolName.hashCode());
135         return result;
136     }
137
138     /* (non-Javadoc)
139      * @see java.lang.Object#equals(java.lang.Object)
140      */
141     @Override
142     public boolean equals(Object obj) {
143         if (this == obj) {
144             return true;
145         }
146         if (obj == null) {
147             return false;
148         }
149         if (!(obj instanceof PoolMember)) {
150             return false;
151         }
152         PoolMember other = (PoolMember) obj;
153         if (ip == null) {
154             if (other.ip != null) {
155                 return false;
156             }
157         }else if (!ip.equals(other.ip)) {
158             return false;
159         }
160         if (poolName == null) {
161             if (other.poolName != null) {
162                 return false;
163             }
164         }else if (!poolName.equals(other.poolName)) {
165             return false;
166         }
167         return true;
168     }
169
170     /* (non-Javadoc)
171      * @see java.lang.Object#toString()
172      */
173     @Override
174     public String toString() {
175         return "PoolMember [name=" + name + ", ip=" + ip + ", poolName="
176                                     + poolName + ", status=" + status + "]";
177     }
178 }