From 68305c2bc711ff844ddabaecf356ea411d3818e1 Mon Sep 17 00:00:00 2001 From: Suchi Raman Date: Mon, 3 Mar 2014 15:00:16 -0500 Subject: [PATCH] * Added HostPairPath to represent path segment from one intermediate host to another intermediate host. * Used in affinity path. Signed-off-by: Suchi Raman --- .../affinity/affinity/HostPairPath.java | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 affinity/api/src/main/java/org/opendaylight/affinity/affinity/HostPairPath.java diff --git a/affinity/api/src/main/java/org/opendaylight/affinity/affinity/HostPairPath.java b/affinity/api/src/main/java/org/opendaylight/affinity/affinity/HostPairPath.java new file mode 100644 index 0000000..62d7613 --- /dev/null +++ b/affinity/api/src/main/java/org/opendaylight/affinity/affinity/HostPairPath.java @@ -0,0 +1,106 @@ + +/* + * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.affinity.affinity; + +import java.io.Serializable; + +import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector; +import org.opendaylight.controller.sal.core.Path; + +/** + * Class that represent a pair of {Host, Path}, the intent of it is to + * be used to represent a sub-path of a waypoint path. See + * AffinityPath for details. + */ + +public class HostPairPath implements Serializable { + private static final long serialVersionUID = 1L; + private HostNodeConnector src; + private HostNodeConnector dst; + private Path path; + + public HostPairPath(HostNodeConnector src, HostNodeConnector dst, Path p) { + setPath(p); + setSource(src); + setDestination(dst); + } + + public Path getPath() { + return path; + } + + public void setPath(Path p) { + this.path = p; + } + + public HostNodeConnector getSource() { + return src; + } + + public void setSource(HostNodeConnector host) { + this.src = host; + } + + public HostNodeConnector getDestination() { + return dst; + } + + public void setDestination(HostNodeConnector host) { + this.dst = host; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((src == null) ? 0 : src.hashCode()); + result = prime * result + ((dst == null) ? 0 : dst.hashCode()); + result = prime * result + ((path == null) ? 0 : path.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + HostPairPath other = (HostPairPath) obj; + if (src == null) { + if (other.src != null) + return false; + } else if (!src.equals(other.src)) + return false; + if (dst == null) { + if (other.dst != null) + return false; + } else if (!dst.equals(other.dst)) + return false; + if (path == null) { + if (other.path != null) + return false; + } else if (!path.equals(other.path)) + return false; + return true; + } + + @Override + public String toString() { + String string; + if (path == null) { + string = "HostPairPath [src=" + src + "dst=" + dst + ", path=" + "(null)" + "]"; + } else { + string = "HostPairPath [src=" + src + "dst=" + dst + ", path=" + path.toString() + "]"; + } + return string; + } +} -- 2.36.6