Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for same host different ports apps #105

Open
wants to merge 2 commits into
base: 1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 == other.getAttributes().get("port"));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is broken. You are comparing strings with "==". It will always be false.

}
}

return equals;
}
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,11 @@ public void hostDown(Instance host) {
}

private TurbineDataMonitor<DataFromSingleInstance> getMonitor(Instance host) {

TurbineDataMonitor<DataFromSingleInstance> monitor = hostConsole.findMonitor(host.getHostname());
String hostName = host.getHostname();
if(host.getAttributes() != null && host.getAttributes().get("port") != null){
hostName += ":" + host.getAttributes().get("port");
}
TurbineDataMonitor<DataFromSingleInstance> monitor = hostConsole.findMonitor(hostName);
if (monitor == null) {
monitor = new InstanceMonitor(host, urlClosure, hostDispatcher, hostConsole);
hostCount.incrementAndGet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down