Add a failover recovery for empty cluster versions (#2473)
* Add a failover recovery for empty cluster versions * Review suggestions
This commit is contained in:
parent
56e4cbf60f
commit
9e1f8d773f
2 changed files with 12 additions and 6 deletions
|
@ -90,10 +90,15 @@ public class ReactiveAdminClient implements Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SupportedFeature getSupportedUpdateFeatureForVersion(String versionStr) {
|
private static SupportedFeature getSupportedUpdateFeatureForVersion(String versionStr) {
|
||||||
float version = NumberUtil.parserClusterVersion(versionStr);
|
try {
|
||||||
return version <= 2.3f
|
float version = NumberUtil.parserClusterVersion(versionStr);
|
||||||
? SupportedFeature.ALTER_CONFIGS
|
return version <= 2.3f
|
||||||
: SupportedFeature.INCREMENTAL_ALTER_CONFIGS;
|
? SupportedFeature.ALTER_CONFIGS
|
||||||
|
: SupportedFeature.INCREMENTAL_ALTER_CONFIGS;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
log.info("Assuming non-incremental alter configs due to version parsing error");
|
||||||
|
return SupportedFeature.ALTER_CONFIGS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: discuss - maybe we should map kafka-library's exceptions to our exceptions here
|
//TODO: discuss - maybe we should map kafka-library's exceptions to our exceptions here
|
||||||
|
|
|
@ -13,7 +13,8 @@ public class NumberUtil {
|
||||||
return value != null && NumberUtils.isCreatable(value.toString());
|
return value != null && NumberUtils.isCreatable(value.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float parserClusterVersion(String version) {
|
public static float parserClusterVersion(String version) throws NumberFormatException {
|
||||||
|
log.trace("Parsing cluster version [{}]", version);
|
||||||
try {
|
try {
|
||||||
final String[] parts = version.split("\\.");
|
final String[] parts = version.split("\\.");
|
||||||
if (parts.length > 2) {
|
if (parts.length > 2) {
|
||||||
|
@ -21,7 +22,7 @@ public class NumberUtil {
|
||||||
}
|
}
|
||||||
return Float.parseFloat(version.split("-")[0]);
|
return Float.parseFloat(version.split("-")[0]);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Conversion clusterVersion {} to float value failed", version);
|
log.error("Conversion clusterVersion [{}] to float value failed", version, e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue