Skip to content

Commit f1c9f7b

Browse files
olim7temerkle826
authored andcommitted
Add IS_LOCAL to /metadata/endpoints response (fixes #372) (#373)
1 parent 1f1d41f commit f1c9f7b

File tree

7 files changed

+13
-1
lines changed

7 files changed

+13
-1
lines changed

management-api-agent-3.x/src/main/java/com/datastax/mgmtapi/shim/CassandraAPI3x.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,12 @@ public List<Map<String, String>> getEndpointStates() {
218218
states.put(s.getKey().name(), value);
219219
}
220220

221-
states.put("ENDPOINT_IP", entry.getKey().getHostAddress());
221+
InetAddress endpoint = entry.getKey();
222+
states.put("ENDPOINT_IP", endpoint.getHostAddress());
222223
states.put("IS_ALIVE", Boolean.toString(entry.getValue().isAlive()));
223224
states.put("PARTITIONER", partitioner.getClass().getName());
224225
states.put("CLUSTER_NAME", getStorageService().getClusterName());
226+
states.put("IS_LOCAL", Boolean.toString(endpoint.equals(FBUtilities.getBroadcastAddress())));
225227

226228
result.add(states);
227229
}

management-api-agent-4.1.x/src/main/java/com/datastax/mgmtapi/shim/CassandraAPI41x.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ public List<Map<String, String>> getEndpointStates() {
256256
states.put("IS_ALIVE", Boolean.toString(state.isAlive()));
257257
states.put("PARTITIONER", partitioner.getClass().getName());
258258
states.put("CLUSTER_NAME", getStorageService().getClusterName());
259+
states.put(
260+
"IS_LOCAL", Boolean.toString(endpoint.equals(FBUtilities.getBroadcastAddressAndPort())));
259261
result.add(states);
260262
}
261263

management-api-agent-4.x/src/main/java/com/datastax/mgmtapi/shim/CassandraAPI4x.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ public List<Map<String, String>> getEndpointStates() {
256256
states.put("IS_ALIVE", Boolean.toString(state.isAlive()));
257257
states.put("PARTITIONER", partitioner.getClass().getName());
258258
states.put("CLUSTER_NAME", getStorageService().getClusterName());
259+
states.put(
260+
"IS_LOCAL", Boolean.toString(endpoint.equals(FBUtilities.getBroadcastAddressAndPort())));
259261
result.add(states);
260262
}
261263

management-api-agent-5.0.x/src/main/java/com/datastax/mgmtapi/shim/CassandraAPI50x.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ public List<Map<String, String>> getEndpointStates() {
256256
states.put("IS_ALIVE", Boolean.toString(state.isAlive()));
257257
states.put("PARTITIONER", partitioner.getClass().getName());
258258
states.put("CLUSTER_NAME", getStorageService().getClusterName());
259+
states.put(
260+
"IS_LOCAL", Boolean.toString(endpoint.equals(FBUtilities.getBroadcastAddressAndPort())));
259261
result.add(states);
260262
}
261263

management-api-agent-dse-6.8/src/main/java/com/datastax/mgmtapi/shim/DseAPI68.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ public List<Map<String, String>> getEndpointStates() {
230230
states.put("IS_ALIVE", Boolean.toString(state.isAlive()));
231231
states.put("PARTITIONER", partitioner.getClass().getName());
232232
states.put("CLUSTER_NAME", getStorageService().getClusterName());
233+
states.put("IS_LOCAL", Boolean.toString(endpoint.equals(FBUtilities.getBroadcastAddress())));
233234
result.add(states);
234235
}
235236

management-api-agent-dse7/src/main/java/com/datastax/mgmtapi/shim/CassandraAPIDse7.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ public List<Map<String, String>> getEndpointStates() {
256256
states.put("IS_ALIVE", Boolean.toString(state.isAlive()));
257257
states.put("PARTITIONER", partitioner.getClass().getName());
258258
states.put("CLUSTER_NAME", getStorageService().getClusterName());
259+
states.put(
260+
"IS_LOCAL", Boolean.toString(endpoint.equals(FBUtilities.getBroadcastAddressAndPort())));
259261
result.add(states);
260262
}
261263

management-api-server/src/test/java/com/datastax/mgmtapi/NonDestructiveOpsIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ public void testGetEndpoints() throws IOException, URISyntaxException {
350350
Map<String, String> endpoint = entity.get(0);
351351
assertThat(endpoint.get("PARTITIONER")).endsWith("Murmur3Partitioner");
352352
assertThat(endpoint.get("CLUSTER_NAME")).matches("Test Cluster");
353+
assertThat(endpoint.get("IS_LOCAL")).isEqualTo("true");
353354
Iterable<String> tokens = Splitter.on(",").split(endpoint.get("TOKENS"));
354355
assertThat(tokens)
355356
.allSatisfy(

0 commit comments

Comments
 (0)