2 * Copyright IBM Corporation, 2013. All rights reserved.
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
8 package org.opendaylight.controller.samples.loadbalancer.entities;
10 import javax.xml.bind.annotation.XmlAccessType;
11 import javax.xml.bind.annotation.XmlAccessorType;
12 import javax.xml.bind.annotation.XmlElement;
13 import javax.xml.bind.annotation.XmlRootElement;
16 * This class represents the Virtual IP (VIP) address exposed by the load balancer application.
17 * Load balancer service differentiates one VIP from the other, using the following three properties:
18 * 1. IP address of the VIP exposed by the application
19 * 2. Protocol of the network traffic (TCP/UDP)
20 * 3. Port to which incoming traffic is destined
22 * User is allowed to create mutliple VIPs with the same IP, but all such VIPs (with the same IP)
23 * should differ at least in the protocol or port or both.
25 * NOTE: Each VIP should have a unique name.
27 @XmlRootElement(name="vip")
28 @XmlAccessorType(XmlAccessType.NONE)
33 * Unique name of the VIP
39 * Virtual IP address of the VIP
45 * Network traffic protocol
48 private String protocol;
51 * Port where network traffic is destined (destination port)
57 * Name of the pool attached to the VIP for load balancing its traffic
59 @XmlElement(name="poolname")
60 private String poolName;
63 * Status (Active/inactive)
66 private String status;
69 * Private constructor used for JAXB mapping
71 @SuppressWarnings("unused")
74 public VIP(String name,
81 this.protocol=protocol;
83 this.poolName = poolName;
86 public String getName() {
90 public void setName(String name) {
94 public String getIp() {
98 public void setIp(String ip) {
102 public String getProtocol() {
106 public void setProtocol(String protocol) {
107 this.protocol = protocol;
110 public short getPort() {
114 public void setPort(short port) {
118 public String getPoolName() {
122 public void setPoolName(String poolName) {
123 this.poolName = poolName;
129 public String getStatus() {
134 * @param status the status to set
136 public void setStatus(String status) {
137 this.status = status;
141 * @see java.lang.Object#hashCode()
144 public int hashCode() {
145 final int prime = 31;
147 result = prime * result + ((ip == null) ? 0 : ip.hashCode());
148 result = prime * result + port;
149 result = prime * result
150 + ((protocol == null) ? 0 : protocol.hashCode());
155 * @see java.lang.Object#equals(java.lang.Object)
158 public boolean equals(Object obj) {
166 if (!(obj instanceof VIP)) {
170 VIP other = (VIP) obj;
172 if (other.ip != null) {
175 }else if (!ip.equals(other.ip)) {
178 if (port != other.port) {
181 if (protocol == null) {
182 if (other.protocol != null) {
185 }else if (!protocol.equalsIgnoreCase(other.protocol)) {
192 * @see java.lang.Object#toString()
195 public String toString() {
196 return "VIP [name=" + name + ", ip=" + ip + ", protocol=" + protocol
197 + ", port=" + port + ", poolName=" + poolName + ", status="