EndpointSnitchInfo: Fix getRack/DC host handling
I.e. our localhost might be (and probably is) different from scyllas "fb::broadcast", and if not, try to get numerical asap.
This commit is contained in:
parent
21a343d003
commit
3fe9cfc232
|
@ -17,6 +17,8 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.cassandra.locator;
|
package org.apache.cassandra.locator;
|
||||||
|
|
||||||
|
import static java.util.Collections.singletonMap;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
@ -49,11 +51,8 @@ public class EndpointSnitchInfo extends APIMBean implements EndpointSnitchInfoMB
|
||||||
@Override
|
@Override
|
||||||
public String getRack(String host) throws UnknownHostException {
|
public String getRack(String host) throws UnknownHostException {
|
||||||
log("getRack(String host) throws UnknownHostException");
|
log("getRack(String host) throws UnknownHostException");
|
||||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
MultivaluedMap<String, String> queryParams = host != null ? new MultivaluedHashMap<String, String>(
|
||||||
if (host == null) {
|
singletonMap("host", InetAddress.getByName(host).getHostAddress())) : null;
|
||||||
host = InetAddress.getLoopbackAddress().getHostAddress();
|
|
||||||
}
|
|
||||||
queryParams.add("host", host);
|
|
||||||
return client.getStringValue("/snitch/rack", queryParams, 10000);
|
return client.getStringValue("/snitch/rack", queryParams, 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,11 +66,8 @@ public class EndpointSnitchInfo extends APIMBean implements EndpointSnitchInfoMB
|
||||||
@Override
|
@Override
|
||||||
public String getDatacenter(String host) throws UnknownHostException {
|
public String getDatacenter(String host) throws UnknownHostException {
|
||||||
log(" getDatacenter(String host) throws UnknownHostException");
|
log(" getDatacenter(String host) throws UnknownHostException");
|
||||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
MultivaluedMap<String, String> queryParams = host != null ? new MultivaluedHashMap<String, String>(
|
||||||
if (host == null) {
|
singletonMap("host", InetAddress.getByName(host).getHostAddress())) : null;
|
||||||
host = InetAddress.getLoopbackAddress().getHostAddress();
|
|
||||||
}
|
|
||||||
queryParams.add("host", host);
|
|
||||||
return client.getStringValue("/snitch/datacenter", queryParams, 10000);
|
return client.getStringValue("/snitch/datacenter", queryParams, 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user