StorageService: Get the broadcast address from the API
When getting the tokens of the current node, we use the get_token api call with the local broadcast address. The current implementation that tries to figure it out from the configuration is prone to error. Currently in a configuration where the broadcast address is set to the local API and the listening API is set to 127.0.0.1 we get a call to nodetool info will return an exception: ID : 54185d5d-6f62-4884-814c-5d17c2776de9 Gossip active : true Thrift active : true Native Transport active: true Load : 178.09 KB Generation No : 1458349593 Uptime (seconds) : 11 Heap Memory (MB) : 47.23 / 247.50 Off Heap Memory (MB) : 2.75 error: Index: 0, Size: 0 -- StackTrace -- java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:653) at java.util.ArrayList.get(ArrayList.java:429) at org.apache.cassandra.tools.NodeProbe.getEndpoint(NodeProbe.java:812) at org.apache.cassandra.tools.NodeProbe.getDataCenter(NodeProbe.java:830) at org.apache.cassandra.tools.NodeTool$Info.execute(NodeTool.java:425) at org.apache.cassandra.tools.NodeTool$NodeToolCmd.run(NodeTool.java:288) at org.apache.cassandra.tools.NodeTool.main(NodeTool.java:202) Becasue getTokens will return an empty list. This patch changed how broadcast address is deduct. It Adds a reverse mapping from hostid to ip address and use it with the get local id to find the ip address in use. This implementation would probably be replaced by a single API call in the future. After the change a call to nodetool info works. Fixes scylladb/scylla#1027 Signed-off-by: Amnon Heiman <amnon@scylladb.com> Message-Id: <1458405434-8491-3-git-send-email-amnon@scylladb.com>
This commit is contained in:
parent
a60c3156c6
commit
94f144e9b3
@ -156,7 +156,13 @@ public class StorageService extends NotificationBroadcasterSupport
|
|||||||
*/
|
*/
|
||||||
public List<String> getTokens() {
|
public List<String> getTokens() {
|
||||||
log(" getTokens()");
|
log(" getTokens()");
|
||||||
return c.getListStrValue("/storage_service/tokens/" + APIConfig.getAddress());
|
try {
|
||||||
|
return getTokens(getLocalBroadCastingAddress());
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
// We should never reach here,
|
||||||
|
// but it makes the compiler happy
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -350,12 +356,25 @@ public class StorageService extends NotificationBroadcasterSupport
|
|||||||
return c.getStringValue("/storage_service/hostid/local");
|
return c.getStringValue("/storage_service/hostid/local");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLocalBroadCastingAddress() {
|
||||||
|
// FIXME:
|
||||||
|
// There is no straight API to get the broadcasting
|
||||||
|
// address, instead of trying to figure it out from the configuration
|
||||||
|
// we will use the getHostIdToAddressMap with the hostid
|
||||||
|
return getHostIdToAddressMap().get(getLocalHostId());
|
||||||
|
}
|
||||||
/** Retrieve the mapping of endpoint to host ID */
|
/** Retrieve the mapping of endpoint to host ID */
|
||||||
public Map<String, String> getHostIdMap() {
|
public Map<String, String> getHostIdMap() {
|
||||||
log(" getHostIdMap()");
|
log(" getHostIdMap()");
|
||||||
return c.getMapStrValue("/storage_service/host_id");
|
return c.getMapStrValue("/storage_service/host_id");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Retrieve the mapping of endpoint to host ID */
|
||||||
|
public Map<String, String> getHostIdToAddressMap() {
|
||||||
|
log(" getHostIdToAddressMap()");
|
||||||
|
return c.getReverseMapStrValue("/storage_service/host_id");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Numeric load value.
|
* Numeric load value.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user