Skip to content

Commit 1ba4f8f

Browse files
authored
Convert sql license objects to LicensedFeature (#78539) (#78626)
This commit moves the license checks for sql jdbc and odbc functionality to use the new LicensedFeature class.
1 parent e9f3337 commit 1ba4f8f

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ public enum Feature {
6464

6565
LOGSTASH(OperationMode.STANDARD, true),
6666

67-
JDBC(OperationMode.PLATINUM, true),
68-
69-
ODBC(OperationMode.PLATINUM, true),
70-
7167
SPATIAL_GEO_CENTROID(OperationMode.GOLD, true),
7268

7369
SPATIAL_GEO_GRID(OperationMode.GOLD, true),

x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlPlugin.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
2222
import org.elasticsearch.env.Environment;
2323
import org.elasticsearch.env.NodeEnvironment;
24+
import org.elasticsearch.license.License;
2425
import org.elasticsearch.license.LicenseUtils;
26+
import org.elasticsearch.license.LicensedFeature;
2527
import org.elasticsearch.license.XPackLicenseState;
2628
import org.elasticsearch.plugins.ActionPlugin;
2729
import org.elasticsearch.plugins.Plugin;
@@ -48,17 +50,20 @@
4850

4951
public class SqlPlugin extends Plugin implements ActionPlugin {
5052

53+
private final LicensedFeature.Momentary JDBC_FEATURE = LicensedFeature.momentary("sql", "jdbc", License.OperationMode.PLATINUM);
54+
private final LicensedFeature.Momentary ODBC_FEATURE = LicensedFeature.momentary("sql", "odbc", License.OperationMode.PLATINUM);
55+
5156
private final SqlLicenseChecker sqlLicenseChecker = new SqlLicenseChecker(
5257
(mode) -> {
5358
XPackLicenseState licenseState = getLicenseState();
5459
switch (mode) {
5560
case JDBC:
56-
if (licenseState.checkFeature(XPackLicenseState.Feature.JDBC) == false) {
61+
if (JDBC_FEATURE.check(licenseState) == false) {
5762
throw LicenseUtils.newComplianceException("jdbc");
5863
}
5964
break;
6065
case ODBC:
61-
if (licenseState.checkFeature(XPackLicenseState.Feature.ODBC) == false) {
66+
if (ODBC_FEATURE.check(licenseState) == false) {
6267
throw LicenseUtils.newComplianceException("odbc");
6368
}
6469
break;

0 commit comments

Comments
 (0)