Skip to content

Commit

Permalink
FMWK-272 Fix arguments in version info calls (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
reugn authored Dec 3, 2023
1 parent d612f92 commit 5227f82
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/main/java/com/aerospike/jdbc/util/VersionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static java.lang.String.format;

public final class VersionUtils {

private static final Logger logger = Logger.getLogger(VersionUtils.class.getName());

private static final String sIndexSupportVersion = "6.0.0.0";
private static final String batchOpsSupportVersion = "6.0.0.0";
private static final String sIndexCardinalitySupportVersion = "6.1.0.0";
private static final String S_INDEX_SUPPORT_VERSION = "6.0.0.0";
private static final String BATCH_OPS_SUPPORT_VERSION = "6.0.0.0";
private static final String S_INDEX_CARDINALITY_SUPPORT_VERSION = "6.1.0.0";
private static final Pattern versionPattern = Pattern.compile("^(\\d.){1,3}\\d(?=.*|$)");

private static volatile Boolean sIndexSupported;
Expand All @@ -28,8 +30,9 @@ public static boolean isSIndexSupported(IAerospikeClient client) {
synchronized (VersionUtils.class) {
if (sIndexSupported == null) {
String serverVersion = clearQualifier(getAerospikeServerVersion(client));
sIndexSupported = compareVersions(serverVersion, sIndexSupportVersion) >= 0;
logger.info(() -> "Secondary index supported: " + sIndexSupported + ", for version: " + serverVersion);
sIndexSupported = compareVersions(serverVersion, S_INDEX_SUPPORT_VERSION) >= 0;
logger.info(() -> format("Secondary index supported: %b, for version: %s",
sIndexSupported, serverVersion));
}
}
}
Expand All @@ -41,8 +44,9 @@ public static boolean isBatchOpsSupported(IAerospikeClient client) {
synchronized (VersionUtils.class) {
if (batchOpsSupported == null) {
String serverVersion = clearQualifier(getAerospikeServerVersion(client));
batchOpsSupported = compareVersions(serverVersion, batchOpsSupportVersion) >= 0;
logger.info(() -> "Batch operations supported: " + batchOpsSupported + ", for version: " + serverVersion);
batchOpsSupported = compareVersions(serverVersion, BATCH_OPS_SUPPORT_VERSION) >= 0;
logger.info(() -> format("Batch operations supported: %b, for version: %s",
batchOpsSupported, serverVersion));
}
}
}
Expand All @@ -54,16 +58,18 @@ public static boolean isSIndexCardinalitySupported(IAerospikeClient client) {
synchronized (VersionUtils.class) {
if (sIndexCardinalitySupported == null) {
String serverVersion = clearQualifier(getAerospikeServerVersion(client));
sIndexCardinalitySupported = compareVersions(serverVersion, sIndexCardinalitySupportVersion) >= 0;
logger.info(() -> "Secondary index cardinality supported: " + sIndexCardinalitySupported + ", for version: " + serverVersion);
sIndexCardinalitySupported = compareVersions(serverVersion, S_INDEX_CARDINALITY_SUPPORT_VERSION) >= 0;
logger.info(() -> format("Secondary index cardinality supported: %b, for version: %s",
sIndexCardinalitySupported, serverVersion));
}
}
}
return sIndexCardinalitySupported;
}

public static String getAerospikeServerVersion(IAerospikeClient client) {
String versionString = Info.request(null, client.getNodes()[0], "version");
String versionString = Info.request(client.getInfoPolicyDefault(),
client.getCluster().getRandomNode(), "version");
return versionString.substring(versionString.lastIndexOf(' ') + 1);
}

Expand Down

0 comments on commit 5227f82

Please sign in to comment.