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;
11 * This class represents the source host that sends any traffic to any existing virtual IP (VIP).
12 * This source host is referred to as a 'Client'. Clients will be differentiated from each other
13 * based on the following three properties:
14 * 1. IP address of the client.
15 * 2. Protocol of the traffic it is using for sending traffic
16 * 3. Source port from which it is sending traffic.
17 * e.g TCP traffic from two different ports from the same host to a given VIP will be considered
18 * as two different clients by this service. Similarly, traffic using two different protocols
19 * (TCP, UDP) from the same host will be considered as two different clients.
25 * IP address of the client (source address)
30 * Network protocol of the traffic sent by client
32 private String protocol;
35 * Port used to send network traffic (source port)
39 public Client(String ip, String protocol, short port){
41 this.protocol = protocol;
46 * @return the client IP
48 public String getIp() {
53 * @param ip the IP to set
55 public void setIp(String ip) {
60 * @return the client network protocol
62 public String getProtocol() {
67 * @param protocol the protocol to set
69 public void setProtocol(String protocol) {
70 this.protocol = protocol;
74 * @return the client port
76 public short getPort() {
81 * @param port the port to set
83 public void setPort(short port) {
88 * @see java.lang.Object#hashCode()
91 public int hashCode() {
94 result = prime * result + ((ip == null) ? 0 : ip.hashCode());
95 result = prime * result + port;
96 result = prime * result+ ((protocol == null) ? 0 : protocol.hashCode());
101 * @see java.lang.Object#equals(java.lang.Object)
104 public boolean equals(Object obj) {
111 if (!(obj instanceof Client)) {
114 Client other = (Client) obj;
116 if (other.ip != null) {
119 }else if (!ip.equals(other.ip)) {
122 if (port != other.port) {
125 if (protocol == null) {
126 if (other.protocol != null) {
129 }else if (!protocol.equals(other.protocol)) {
136 * @see java.lang.Object#toString()
139 public String toString() {
140 return "Client [ip=" + ip + ", protocol=" + protocol + ", port=" + port+ "]";