nuked ESLicenseProvider; minor cleanups

Original commit: elastic/x-pack-elasticsearch@92af8dc307
This commit is contained in:
Areek Zillur 2014-10-22 17:46:46 -04:00
parent 1f153402ef
commit 996f7aadf7
6 changed files with 8 additions and 52 deletions

View File

@ -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<String, ESLicense> esLicenses;
public FileBasedESLicenseProvider(Set<ESLicense> esLicenses) {
this.esLicenses = Utils.reduceAndMap(esLicenses);
}
@Override
public ESLicense getESLicense(String feature) {
return esLicenses.get(feature);
}
@Override
public Map<String, ESLicense> getEffectiveLicenses() {
return esLicenses;
}

View File

@ -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();

View File

@ -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<String, ESLicense> getEffectiveLicenses();
}

View File

@ -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<LicensesService> implements ESLicenseProvider, ClusterStateListener, LicensesManagerService, LicensesClientService {
public class LicensesService extends AbstractLifecycleComponent<LicensesService> implements ClusterStateListener, LicensesManagerService, LicensesClientService {
private ESLicenseManager esLicenseManager;
@ -74,7 +73,9 @@ public class LicensesService extends AbstractLifecycleComponent<LicensesService>
* Registers new licenses in the cluster
* <p/>
* 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<ClusterStateUpdateResponse> listener) {
@ -313,12 +314,6 @@ public class LicensesService extends AbstractLifecycleComponent<LicensesService>
return ThreadPool.Names.GENERIC;
}
@Override
public ESLicense getESLicense(String feature) {
return getEffectiveLicenses().get(feature);
}
@Override
public Map<String, ESLicense> getEffectiveLicenses() {
final ClusterState state = clusterService.state();
LicensesMetaData metaData = state.metaData().custom(LicensesMetaData.TYPE);

View File

@ -173,7 +173,7 @@ public class LicenseVerificationTests extends AbstractLicensingTestBase {
}
}
public static void verifyLicenseManager(ESLicenseManager esLicenseManager, ESLicenseProvider licenseProvider, Map<String, TestUtils.FeatureAttributes> featureAttributeMap) throws ParseException {
public static void verifyLicenseManager(ESLicenseManager esLicenseManager, FileBasedESLicenseProvider licenseProvider, Map<String, TestUtils.FeatureAttributes> featureAttributeMap) throws ParseException {
for (Map.Entry<String, TestUtils.FeatureAttributes> entry : featureAttributeMap.entrySet()) {
TestUtils.FeatureAttributes featureAttributes = entry.getValue();

View File

@ -31,18 +31,4 @@ public class TestConsumerPlugin extends AbstractPlugin {
public Collection<Class<? extends LifecycleComponent>> services() {
return ImmutableSet.<Class<? extends LifecycleComponent>>of(TestPluginService.class);
}
/*
@Override
public Collection<Class<? extends Module>> modules() {
return ImmutableSet.<Class<? extends Module>>of(TestPluginServiceModule.class);
}
public class TestPluginServiceModule extends AbstractModule {
@Override
protected void configure() {
bind(TestPluginService.class).in(Scopes.SINGLETON);
}
}
*/
}