Skip to content

Commit

Permalink
add timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
agrgr committed Jul 21, 2024
1 parent 8e944ad commit ee5edf6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.TimeUnit;

@Slf4j
@UtilityClass
Expand Down Expand Up @@ -48,7 +49,7 @@ public void onFailure(AerospikeException ae) {

String value = null;
try {
value = listener.getValueFuture().join();
value = listener.getValueFuture().orTimeout(infoPolicy.timeout, TimeUnit.MILLISECONDS).join();
} catch (CompletionException ce) {
fail(command, ce.getCause());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ static void createIndex(IAerospikeClient client, ServerVersionSupport serverVers

public static List<Index> getIndexes(IAerospikeClient client, String namespace, IndexInfoParser indexInfoParser) {
Node node = client.getCluster().getRandomNode();
String response = InfoCommandUtils.request(client, node, "sindex-list:ns=" + namespace + ";b64=true"
);
String response = InfoCommandUtils.request(client, node, "sindex-list:ns=" + namespace + ";b64=true");
return Arrays.stream(response.split(";"))
.map(indexInfoParser::parse)
.collect(Collectors.toList());
Expand All @@ -57,8 +56,7 @@ public static List<Index> getIndexes(IAerospikeClient client, String namespace,
*/
public static boolean indexExists(IAerospikeClient client, String namespace, String indexName) {
Node node = client.getCluster().getRandomNode();
String response = InfoCommandUtils.request(client, node, "sindex/" + namespace + '/' + indexName
);
String response = InfoCommandUtils.request(client, node, "sindex/" + namespace + '/' + indexName);
return !response.startsWith("FAIL:201");
}

Expand Down

0 comments on commit ee5edf6

Please sign in to comment.