diff --git a/src/main/java/org/elasticsearch/license/licensor/tools/FileBasedESLicenseProvider.java b/src/main/java/org/elasticsearch/license/licensor/tools/FileBasedESLicenseProvider.java index dc5affbac50..f6abbfd4a90 100644 --- a/src/main/java/org/elasticsearch/license/licensor/tools/FileBasedESLicenseProvider.java +++ b/src/main/java/org/elasticsearch/license/licensor/tools/FileBasedESLicenseProvider.java @@ -7,7 +7,6 @@ package org.elasticsearch.license.licensor.tools; import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.license.core.ESLicense; -import org.elasticsearch.license.manager.ESLicenseProvider; import org.elasticsearch.license.manager.Utils; import java.util.Map; @@ -15,19 +14,17 @@ import java.util.Set; /** */ -public class FileBasedESLicenseProvider implements ESLicenseProvider { +public class FileBasedESLicenseProvider { private ImmutableMap esLicenses; public FileBasedESLicenseProvider(Set esLicenses) { this.esLicenses = Utils.reduceAndMap(esLicenses); } - @Override public ESLicense getESLicense(String feature) { return esLicenses.get(feature); } - @Override public Map getEffectiveLicenses() { return esLicenses; } diff --git a/src/main/java/org/elasticsearch/license/licensor/tools/LicenseVerificationTool.java b/src/main/java/org/elasticsearch/license/licensor/tools/LicenseVerificationTool.java index 69489c68058..7da3acba810 100644 --- a/src/main/java/org/elasticsearch/license/licensor/tools/LicenseVerificationTool.java +++ b/src/main/java/org/elasticsearch/license/licensor/tools/LicenseVerificationTool.java @@ -11,7 +11,6 @@ import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.license.core.ESLicense; import org.elasticsearch.license.core.ESLicenses; import org.elasticsearch.license.manager.ESLicenseManager; -import org.elasticsearch.license.manager.ESLicenseProvider; import java.io.File; import java.io.IOException; @@ -75,13 +74,11 @@ public class LicenseVerificationTool { Options options = parse(args); // verify licenses - ESLicenseProvider licenseProvider = new FileBasedESLicenseProvider(options.licenses); + FileBasedESLicenseProvider licenseProvider = new FileBasedESLicenseProvider(options.licenses); ESLicenseManager licenseManager = new ESLicenseManager(); licenseManager.verifyLicenses(licenseProvider.getEffectiveLicenses()); // dump effective licences - //LicenseUtils.dumpLicenseAsJson(licenseManager.getEffectiveLicenses(), out); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON, out); ESLicenses.toXContent(licenseProvider.getEffectiveLicenses().values(), builder); builder.flush(); diff --git a/src/main/java/org/elasticsearch/license/manager/ESLicenseProvider.java b/src/main/java/org/elasticsearch/license/manager/ESLicenseProvider.java deleted file mode 100644 index f2c706fca72..00000000000 --- a/src/main/java/org/elasticsearch/license/manager/ESLicenseProvider.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.license.manager; - - -import org.elasticsearch.license.core.ESLicense; - -import java.util.Map; - - -public interface ESLicenseProvider { - - ESLicense getESLicense(String feature); - - Map getEffectiveLicenses(); -} diff --git a/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java b/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java index cacb7d0ed6c..8280976eb34 100644 --- a/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java +++ b/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java @@ -26,7 +26,6 @@ import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; import org.elasticsearch.gateway.GatewayService; import org.elasticsearch.license.core.ESLicense; import org.elasticsearch.license.manager.ESLicenseManager; -import org.elasticsearch.license.manager.ESLicenseProvider; import org.elasticsearch.license.plugin.action.delete.DeleteLicenseRequest; import org.elasticsearch.license.plugin.action.put.PutLicenseRequest; import org.elasticsearch.license.plugin.core.trial.TrialLicenseUtils; @@ -47,10 +46,10 @@ import static org.elasticsearch.license.plugin.core.trial.TrialLicenses.TrialLic * - LicensesManagerService - responsible for adding/deleting signed licenses * - LicensesClientService - allow interested plugins (features) to register to licensing notifications * - * TODO: documentation; remove ESLicenseProvider interface (almost done) + * TODO: documentation */ @Singleton -public class LicensesService extends AbstractLifecycleComponent implements ESLicenseProvider, ClusterStateListener, LicensesManagerService, LicensesClientService { +public class LicensesService extends AbstractLifecycleComponent implements ClusterStateListener, LicensesManagerService, LicensesClientService { private ESLicenseManager esLicenseManager; @@ -74,7 +73,9 @@ public class LicensesService extends AbstractLifecycleComponent * Registers new licenses in the cluster *

* This method can be only called on the master node. It tries to create a new licenses on the master - * and if it was successful it adds the license to cluster metadata. + * and if provided license(s) is VALID it is added to cluster metadata. + * + * @return LicensesStatus indicating if the provided license(s) is VALID (accepted), INVALID (tampered license) or EXPIRED */ @Override public LicensesStatus registerLicenses(final PutLicenseRequestHolder requestHolder, final ActionListener listener) { @@ -313,12 +314,6 @@ public class LicensesService extends AbstractLifecycleComponent return ThreadPool.Names.GENERIC; } - @Override - public ESLicense getESLicense(String feature) { - return getEffectiveLicenses().get(feature); - } - - @Override public Map getEffectiveLicenses() { final ClusterState state = clusterService.state(); LicensesMetaData metaData = state.metaData().custom(LicensesMetaData.TYPE); diff --git a/src/test/java/org/elasticsearch/license/manager/LicenseVerificationTests.java b/src/test/java/org/elasticsearch/license/manager/LicenseVerificationTests.java index 22c6e8110fa..5f4eb511574 100644 --- a/src/test/java/org/elasticsearch/license/manager/LicenseVerificationTests.java +++ b/src/test/java/org/elasticsearch/license/manager/LicenseVerificationTests.java @@ -173,7 +173,7 @@ public class LicenseVerificationTests extends AbstractLicensingTestBase { } } - public static void verifyLicenseManager(ESLicenseManager esLicenseManager, ESLicenseProvider licenseProvider, Map featureAttributeMap) throws ParseException { + public static void verifyLicenseManager(ESLicenseManager esLicenseManager, FileBasedESLicenseProvider licenseProvider, Map featureAttributeMap) throws ParseException { for (Map.Entry entry : featureAttributeMap.entrySet()) { TestUtils.FeatureAttributes featureAttributes = entry.getValue(); diff --git a/src/test/java/org/elasticsearch/license/plugin/TestConsumerPlugin.java b/src/test/java/org/elasticsearch/license/plugin/TestConsumerPlugin.java index 20a6a8a85fe..e545cdc6b65 100644 --- a/src/test/java/org/elasticsearch/license/plugin/TestConsumerPlugin.java +++ b/src/test/java/org/elasticsearch/license/plugin/TestConsumerPlugin.java @@ -31,18 +31,4 @@ public class TestConsumerPlugin extends AbstractPlugin { public Collection> services() { return ImmutableSet.>of(TestPluginService.class); } - - /* - @Override - public Collection> modules() { - return ImmutableSet.>of(TestPluginServiceModule.class); - } - - public class TestPluginServiceModule extends AbstractModule { - @Override - protected void configure() { - bind(TestPluginService.class).in(Scopes.SINGLETON); - } - } - */ }