Skip to content

Commit

Permalink
FMWK-511 Filter for active nodes in info requests (#764)
Browse files Browse the repository at this point in the history
  • Loading branch information
reugn authored Jul 25, 2024
1 parent eb05ff4 commit 751ebb1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,7 @@ public boolean indexExists(String indexName) {
try {
Node[] nodes = client.getNodes();
for (Node node : nodes) {
if (!node.isActive()) continue;
String response = InfoCommandUtils.request(client, node, "sindex-exists:ns=" + namespace +
";indexname=" + indexName);
if (response == null) throw new AerospikeException("Null node response");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,7 @@ public Mono<Boolean> indexExists(String indexName) {
try {
Node[] nodes = reactorClient.getAerospikeClient().getNodes();
for (Node node : nodes) {
if (!node.isActive()) continue;
String response = InfoCommandUtils.request(reactorClient.getAerospikeClient(), node,
"sindex-exists:ns=" + namespace + ";indexname=" + indexName);
if (response == null) throw new AerospikeException("Null node response");
Expand Down
13 changes: 5 additions & 8 deletions src/main/java/org/springframework/data/aerospike/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,11 @@ public class Utils {
* @return An "Info" value for the given variable from all the nodes in the cluster.
*/
@SuppressWarnings("UnusedReturnValue")
public static String[] infoAll(IAerospikeClient client,
String infoString) {
String[] messages = new String[client.getNodes().length];
int index = 0;
for (Node node : client.getNodes()) {
messages[index] = Info.request(client.getInfoPolicyDefault(), node, infoString);
}
return messages;
public static String[] infoAll(IAerospikeClient client, String infoString) {
return Arrays.stream(client.getNodes())
.filter(Node::isActive)
.map(node -> Info.request(client.getInfoPolicyDefault(), node, infoString))
.toArray(String[]::new);
}

public static int getReplicationFactor(IAerospikeClient client, Node[] nodes, String namespace) {
Expand Down

0 comments on commit 751ebb1

Please sign in to comment.