From d05c01b1a886abd7408807bdb76d29983b31bf25 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Thu, 30 Sep 2021 15:28:08 -0700 Subject: [PATCH] Convert sql license objects to LicensedFeature This commit moves the license checks for sql jdbc and odbc functionality to use the new LicensedFeature class. --- .../org/elasticsearch/license/XPackLicenseState.java | 4 ---- .../org/elasticsearch/xpack/sql/plugin/SqlPlugin.java | 9 +++++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java index 3a27e0cbe8dcc..5682a32a20e4c 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java @@ -64,10 +64,6 @@ public enum Feature { LOGSTASH(OperationMode.STANDARD, true), - JDBC(OperationMode.PLATINUM, true), - - ODBC(OperationMode.PLATINUM, true), - SPATIAL_GEO_CENTROID(OperationMode.GOLD, true), SPATIAL_GEO_GRID(OperationMode.GOLD, true), diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlPlugin.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlPlugin.java index ab519eb241245..d254416aeb42e 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlPlugin.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/SqlPlugin.java @@ -20,7 +20,9 @@ import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.env.Environment; import org.elasticsearch.env.NodeEnvironment; +import org.elasticsearch.license.License; import org.elasticsearch.license.LicenseUtils; +import org.elasticsearch.license.LicensedFeature; import org.elasticsearch.license.XPackLicenseState; import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.Plugin; @@ -49,17 +51,20 @@ public class SqlPlugin extends Plugin implements ActionPlugin { + private final LicensedFeature.Momentary JDBC_FEATURE = LicensedFeature.momentary("sql", "jdbc", License.OperationMode.PLATINUM); + private final LicensedFeature.Momentary ODBC_FEATURE = LicensedFeature.momentary("sql", "odbc", License.OperationMode.PLATINUM); + private final SqlLicenseChecker sqlLicenseChecker = new SqlLicenseChecker( (mode) -> { XPackLicenseState licenseState = getLicenseState(); switch (mode) { case JDBC: - if (licenseState.checkFeature(XPackLicenseState.Feature.JDBC) == false) { + if (JDBC_FEATURE.check(licenseState) == false) { throw LicenseUtils.newComplianceException("jdbc"); } break; case ODBC: - if (licenseState.checkFeature(XPackLicenseState.Feature.ODBC) == false) { + if (ODBC_FEATURE.check(licenseState) == false) { throw LicenseUtils.newComplianceException("odbc"); } break;