diff --git a/turbine-core/src/main/java/com/netflix/turbine/discovery/Instance.java b/turbine-core/src/main/java/com/netflix/turbine/discovery/Instance.java index 8d2d661..3b41dfa 100644 --- a/turbine-core/src/main/java/com/netflix/turbine/discovery/Instance.java +++ b/turbine-core/src/main/java/com/netflix/turbine/discovery/Instance.java @@ -74,6 +74,12 @@ public boolean equals(Object obj) { equals &= (this.hostname != null) ? (this.hostname.equals(other.hostname)) : (other.hostname == null); equals &= (this.cluster != null) ? (this.cluster.equals(other.cluster)) : (other.cluster == null); equals &= (this.isUp == other.isUp); + if(attributes != null && attributes.get("port") != null){ + String port = attributes.get("port"); + if(other.getAttributes() != null && other.getAttributes().get("port") != null){ + equals &= (port.equals(other.getAttributes().get("port"))); + } + } return equals; } @@ -85,6 +91,9 @@ public int hashCode() { result = prime * result + ((hostname == null) ? 0 : hostname.hashCode()); result = prime * result + ((cluster == null) ? 0 : cluster.hashCode()); result = prime * result + (isUp ? 1 : 0); + if(attributes != null && attributes.get("port") != null){ + result = prime * result + (attributes.get("port").hashCode()); + } return result; } diff --git a/turbine-core/src/main/java/com/netflix/turbine/monitor/cluster/ClusterMonitor.java b/turbine-core/src/main/java/com/netflix/turbine/monitor/cluster/ClusterMonitor.java index 41d7fce..45c48a2 100644 --- a/turbine-core/src/main/java/com/netflix/turbine/monitor/cluster/ClusterMonitor.java +++ b/turbine-core/src/main/java/com/netflix/turbine/monitor/cluster/ClusterMonitor.java @@ -294,8 +294,11 @@ public void hostDown(Instance host) { } private TurbineDataMonitor getMonitor(Instance host) { - - TurbineDataMonitor monitor = hostConsole.findMonitor(host.getHostname()); + String hostName = host.getHostname(); + if(host.getAttributes() != null && host.getAttributes().get("port") != null){ + hostName += ":" + host.getAttributes().get("port"); + } + TurbineDataMonitor monitor = hostConsole.findMonitor(hostName); if (monitor == null) { monitor = new InstanceMonitor(host, urlClosure, hostDispatcher, hostConsole); hostCount.incrementAndGet(); diff --git a/turbine-core/src/main/java/com/netflix/turbine/monitor/instance/InstanceMonitor.java b/turbine-core/src/main/java/com/netflix/turbine/monitor/instance/InstanceMonitor.java index b7145be..c7bf466 100644 --- a/turbine-core/src/main/java/com/netflix/turbine/monitor/instance/InstanceMonitor.java +++ b/turbine-core/src/main/java/com/netflix/turbine/monitor/instance/InstanceMonitor.java @@ -198,7 +198,11 @@ private InstanceMonitor(Instance host, */ @Override public String getName() { - return host.getHostname(); + String hostName = host.getHostname(); + if(this.host.getAttributes() != null && this.host.getAttributes().get("port") != null){ + hostName += ":" + this.host.getAttributes().get("port"); + } + return hostName; } /**