Merge pull request elastic/elasticsearch#2891 from rjernst/license_service_name
Rename LicensesService to LicenseService Original commit: elastic/x-pack-elasticsearch@e9c3058ca1
This commit is contained in:
commit
dcb9145b93
|
@ -20,7 +20,7 @@ import org.elasticsearch.license.plugin.action.get.TransportGetLicenseAction;
|
|||
import org.elasticsearch.license.plugin.action.put.PutLicenseAction;
|
||||
import org.elasticsearch.license.plugin.action.put.TransportPutLicenseAction;
|
||||
import org.elasticsearch.license.plugin.core.LicensesMetaData;
|
||||
import org.elasticsearch.license.plugin.core.LicensesService;
|
||||
import org.elasticsearch.license.plugin.core.LicenseService;
|
||||
import org.elasticsearch.license.plugin.rest.RestDeleteLicenseAction;
|
||||
import org.elasticsearch.license.plugin.rest.RestGetLicenseAction;
|
||||
import org.elasticsearch.license.plugin.rest.RestPutLicenseAction;
|
||||
|
@ -92,11 +92,11 @@ public class Licensing implements ActionPlugin {
|
|||
WatcherLicensee watcherLicensee = new WatcherLicensee(settings);
|
||||
MonitoringLicensee monitoringLicensee = new MonitoringLicensee(settings);
|
||||
GraphLicensee graphLicensee = new GraphLicensee(settings);
|
||||
LicensesService licensesService = new LicensesService(settings, clusterService, clock,
|
||||
LicenseService licenseService = new LicenseService(settings, clusterService, clock,
|
||||
environment, resourceWatcherService,
|
||||
Arrays.asList(securityLicensee, watcherLicensee, monitoringLicensee, graphLicensee));
|
||||
|
||||
return Arrays.asList(licensesService, securityLicenseState, securityLicensee, watcherLicensee, monitoringLicensee, graphLicensee);
|
||||
return Arrays.asList(licenseService, securityLicenseState, securityLicensee, watcherLicensee, monitoringLicensee, graphLicensee);
|
||||
}
|
||||
|
||||
public List<Setting<?>> getSettings() {
|
||||
|
|
|
@ -17,21 +17,21 @@ import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
|||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.plugin.core.LicensesService;
|
||||
import org.elasticsearch.license.plugin.core.LicenseService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
public class TransportDeleteLicenseAction extends TransportMasterNodeAction<DeleteLicenseRequest, DeleteLicenseResponse> {
|
||||
|
||||
private final LicensesService licensesService;
|
||||
private final LicenseService licenseService;
|
||||
|
||||
@Inject
|
||||
public TransportDeleteLicenseAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
LicensesService licensesService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||
LicenseService licenseService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, DeleteLicenseAction.NAME, transportService, clusterService, threadPool, actionFilters,
|
||||
indexNameExpressionResolver, DeleteLicenseRequest::new);
|
||||
this.licensesService = licensesService;
|
||||
this.licenseService = licenseService;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,7 +52,7 @@ public class TransportDeleteLicenseAction extends TransportMasterNodeAction<Dele
|
|||
@Override
|
||||
protected void masterOperation(final DeleteLicenseRequest request, ClusterState state, final ActionListener<DeleteLicenseResponse>
|
||||
listener) throws ElasticsearchException {
|
||||
licensesService.removeLicense(request, new ActionListener<ClusterStateUpdateResponse>() {
|
||||
licenseService.removeLicense(request, new ActionListener<ClusterStateUpdateResponse>() {
|
||||
@Override
|
||||
public void onResponse(ClusterStateUpdateResponse clusterStateUpdateResponse) {
|
||||
listener.onResponse(new DeleteLicenseResponse(clusterStateUpdateResponse.isAcknowledged()));
|
||||
|
|
|
@ -16,21 +16,21 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
|||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.plugin.core.LicensesService;
|
||||
import org.elasticsearch.license.plugin.core.LicenseService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
public class TransportGetLicenseAction extends TransportMasterNodeReadAction<GetLicenseRequest, GetLicenseResponse> {
|
||||
|
||||
private final LicensesService licensesService;
|
||||
private final LicenseService licenseService;
|
||||
|
||||
@Inject
|
||||
public TransportGetLicenseAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
LicensesService licensesService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||
LicenseService licenseService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, GetLicenseAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver,
|
||||
GetLicenseRequest::new);
|
||||
this.licensesService = licensesService;
|
||||
this.licenseService = licenseService;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -51,6 +51,6 @@ public class TransportGetLicenseAction extends TransportMasterNodeReadAction<Get
|
|||
@Override
|
||||
protected void masterOperation(final GetLicenseRequest request, ClusterState state, final ActionListener<GetLicenseResponse>
|
||||
listener) throws ElasticsearchException {
|
||||
listener.onResponse(new GetLicenseResponse(licensesService.getLicense()));
|
||||
listener.onResponse(new GetLicenseResponse(licenseService.getLicense()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,21 +16,21 @@ import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
|||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.plugin.core.LicensesService;
|
||||
import org.elasticsearch.license.plugin.core.LicenseService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
public class TransportPutLicenseAction extends TransportMasterNodeAction<PutLicenseRequest, PutLicenseResponse> {
|
||||
|
||||
private final LicensesService licensesService;
|
||||
private final LicenseService licenseService;
|
||||
|
||||
@Inject
|
||||
public TransportPutLicenseAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
LicensesService licensesService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||
LicenseService licenseService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, PutLicenseAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver,
|
||||
PutLicenseRequest::new);
|
||||
this.licensesService = licensesService;
|
||||
this.licenseService = licenseService;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -51,7 +51,7 @@ public class TransportPutLicenseAction extends TransportMasterNodeAction<PutLice
|
|||
@Override
|
||||
protected void masterOperation(final PutLicenseRequest request, ClusterState state, final ActionListener<PutLicenseResponse>
|
||||
listener) throws ElasticsearchException {
|
||||
licensesService.registerLicense(request, listener);
|
||||
licenseService.registerLicense(request, listener);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ import java.util.stream.Collectors;
|
|||
* When a new license is notified as enabled to the registered listener, a notification is scheduled at the time of license expiry.
|
||||
* Registered listeners are notified using {@link #onUpdate(LicensesMetaData)}
|
||||
*/
|
||||
public class LicensesService extends AbstractLifecycleComponent implements ClusterStateListener, SchedulerEngine.Listener {
|
||||
public class LicenseService extends AbstractLifecycleComponent implements ClusterStateListener, SchedulerEngine.Listener {
|
||||
|
||||
// pkg private for tests
|
||||
static final TimeValue TRIAL_LICENSE_DURATION = TimeValue.timeValueHours(30 * 24);
|
||||
|
@ -98,8 +98,8 @@ public class LicensesService extends AbstractLifecycleComponent implements Clust
|
|||
private static final String ACKNOWLEDGEMENT_HEADER = "This license update requires acknowledgement. To acknowledge the license, " +
|
||||
"please read the following messages and update the license again, this time with the \"acknowledge=true\" parameter:";
|
||||
|
||||
public LicensesService(Settings settings, ClusterService clusterService, Clock clock, Environment env,
|
||||
ResourceWatcherService resourceWatcherService, List<Licensee> registeredLicensees) {
|
||||
public LicenseService(Settings settings, ClusterService clusterService, Clock clock, Environment env,
|
||||
ResourceWatcherService resourceWatcherService, List<Licensee> registeredLicensees) {
|
||||
super(settings);
|
||||
this.clusterService = clusterService;
|
||||
this.clock = clock;
|
|
@ -8,7 +8,7 @@ package org.elasticsearch.license.plugin.core;
|
|||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.license.core.License;
|
||||
|
||||
import static org.elasticsearch.license.plugin.core.LicensesService.days;
|
||||
import static org.elasticsearch.license.plugin.core.LicenseService.days;
|
||||
|
||||
/**
|
||||
* States of a registered licensee
|
||||
|
|
|
@ -10,8 +10,8 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.license.core.License;
|
||||
import org.elasticsearch.license.plugin.core.LicenseService;
|
||||
import org.elasticsearch.license.plugin.core.LicenseState;
|
||||
import org.elasticsearch.license.plugin.core.LicensesService;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||
import org.elasticsearch.xpack.MockNetty3Plugin;
|
||||
|
@ -170,7 +170,7 @@ public class LicensesServiceClusterTests extends AbstractLicensesIntegrationTest
|
|||
|
||||
private void assertLicenseState(LicenseState state) throws InterruptedException {
|
||||
boolean success = awaitBusy(() -> {
|
||||
for (LicensesService service : internalCluster().getDataNodeInstances(LicensesService.class)) {
|
||||
for (LicenseService service : internalCluster().getDataNodeInstances(LicenseService.class)) {
|
||||
if (service.licenseeStatus().getLicenseState() == state) {
|
||||
return true;
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ public class LicensesServiceClusterTests extends AbstractLicensesIntegrationTest
|
|||
|
||||
private void assertOperationMode(License.OperationMode operationMode) throws InterruptedException {
|
||||
boolean success = awaitBusy(() -> {
|
||||
for (LicensesService service : internalCluster().getDataNodeInstances(LicensesService.class)) {
|
||||
for (LicenseService service : internalCluster().getDataNodeInstances(LicenseService.class)) {
|
||||
if (service.licenseeStatus().getMode() == operationMode) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@ import org.elasticsearch.license.core.License;
|
|||
import org.elasticsearch.license.licensor.LicenseSigner;
|
||||
import org.elasticsearch.license.plugin.action.put.PutLicenseRequest;
|
||||
import org.elasticsearch.license.plugin.action.put.PutLicenseResponse;
|
||||
import org.elasticsearch.license.plugin.core.LicenseService;
|
||||
import org.elasticsearch.license.plugin.core.Licensee;
|
||||
import org.elasticsearch.license.plugin.core.LicensesService;
|
||||
import org.elasticsearch.license.plugin.core.LicensesStatus;
|
||||
import org.junit.Assert;
|
||||
|
||||
|
@ -146,12 +146,12 @@ public class TestUtils {
|
|||
return PathUtils.get(TestUtils.class.getResource(resource).toURI());
|
||||
}
|
||||
|
||||
public static void registerAndAckSignedLicenses(final LicensesService licensesService, License license,
|
||||
public static void registerAndAckSignedLicenses(final LicenseService licenseService, License license,
|
||||
final LicensesStatus expectedStatus) {
|
||||
PutLicenseRequest putLicenseRequest = new PutLicenseRequest().license(license).acknowledge(true);
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final AtomicReference<LicensesStatus> status = new AtomicReference<>();
|
||||
licensesService.registerLicense(putLicenseRequest, new ActionListener<PutLicenseResponse>() {
|
||||
licenseService.registerLicense(putLicenseRequest, new ActionListener<PutLicenseResponse>() {
|
||||
@Override
|
||||
public void onResponse(PutLicenseResponse licensesUpdateResponse) {
|
||||
status.set(licensesUpdateResponse.status());
|
||||
|
|
|
@ -35,7 +35,7 @@ import static org.mockito.Mockito.when;
|
|||
|
||||
public abstract class AbstractLicenseServiceTestCase extends ESTestCase {
|
||||
|
||||
protected LicensesService licensesService;
|
||||
protected LicenseService licenseService;
|
||||
protected ClusterService clusterService;
|
||||
protected ResourceWatcherService resourceWatcherService;
|
||||
protected ClockMock clock;
|
||||
|
@ -54,7 +54,7 @@ public abstract class AbstractLicenseServiceTestCase extends ESTestCase {
|
|||
protected void setInitialState(License license, Licensee... licensees) {
|
||||
Path tempDir = createTempDir();
|
||||
when(environment.configFile()).thenReturn(tempDir);
|
||||
licensesService = new LicensesService(Settings.EMPTY, clusterService, clock, environment,
|
||||
licenseService = new LicenseService(Settings.EMPTY, clusterService, clock, environment,
|
||||
resourceWatcherService, Arrays.asList(licensees));
|
||||
ClusterState state = mock(ClusterState.class);
|
||||
final ClusterBlocks noBlock = ClusterBlocks.builder().build();
|
||||
|
@ -74,6 +74,6 @@ public abstract class AbstractLicenseServiceTestCase extends ESTestCase {
|
|||
|
||||
@After
|
||||
public void after() {
|
||||
licensesService.stop();
|
||||
licenseService.stop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,12 +37,12 @@ public class LicenseClusterChangeTests extends AbstractLicenseServiceTestCase {
|
|||
public void setup() {
|
||||
licensee = new TestUtils.AssertingLicensee("LicenseClusterChangeTests", logger);
|
||||
setInitialState(null, licensee);
|
||||
licensesService.start();
|
||||
licenseService.start();
|
||||
}
|
||||
|
||||
@After
|
||||
public void teardown() {
|
||||
licensesService.stop();
|
||||
licenseService.stop();
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class LicenseClusterChangeTests extends AbstractLicenseServiceTestCase {
|
|||
final License license = TestUtils.generateSignedLicense(TimeValue.timeValueHours(24));
|
||||
MetaData metaData = MetaData.builder().putCustom(LicensesMetaData.TYPE, new LicensesMetaData(license)).build();
|
||||
ClusterState newState = ClusterState.builder(new ClusterName("a")).metaData(metaData).build();
|
||||
licensesService.clusterChanged(new ClusterChangedEvent("simulated", newState, oldState));
|
||||
licenseService.clusterChanged(new ClusterChangedEvent("simulated", newState, oldState));
|
||||
assertThat(licensee.statuses.size(), equalTo(1));
|
||||
assertTrue(licensee.statuses.get(0).getLicenseState() == LicenseState.ENABLED);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class LicenseClusterChangeTests extends AbstractLicenseServiceTestCase {
|
|||
MetaData metaData = MetaData.builder().putCustom(LicensesMetaData.TYPE, new LicensesMetaData(license)).build();
|
||||
ClusterState newState = ClusterState.builder(new ClusterName("a")).metaData(metaData).build();
|
||||
ClusterState oldState = ClusterState.builder(newState).build();
|
||||
licensesService.clusterChanged(new ClusterChangedEvent("simulated", newState, oldState));
|
||||
licenseService.clusterChanged(new ClusterChangedEvent("simulated", newState, oldState));
|
||||
assertThat(licensee.statuses.size(), equalTo(0));
|
||||
}
|
||||
|
||||
|
@ -72,13 +72,13 @@ public class LicenseClusterChangeTests extends AbstractLicenseServiceTestCase {
|
|||
when(discoveryNodes.isLocalNodeElectedMaster()).thenReturn(true);
|
||||
ClusterState newState = ClusterState.builder(oldState).nodes(discoveryNodes).build();
|
||||
|
||||
licensesService.clusterChanged(new ClusterChangedEvent("simulated", newState, oldState));
|
||||
licenseService.clusterChanged(new ClusterChangedEvent("simulated", newState, oldState));
|
||||
ArgumentCaptor<ClusterStateUpdateTask> stateUpdater = ArgumentCaptor.forClass(ClusterStateUpdateTask.class);
|
||||
verify(clusterService, times(1)).submitStateUpdateTask(any(), stateUpdater.capture());
|
||||
ClusterState stateWithLicense = stateUpdater.getValue().execute(newState);
|
||||
LicensesMetaData licenseMetaData = stateWithLicense.metaData().custom(LicensesMetaData.TYPE);
|
||||
assertNotNull(licenseMetaData);
|
||||
assertNotNull(licenseMetaData.getLicense());
|
||||
assertEquals(clock.millis() + LicensesService.TRIAL_LICENSE_DURATION.millis(), licenseMetaData.getLicense().expiryDate());
|
||||
assertEquals(clock.millis() + LicenseService.TRIAL_LICENSE_DURATION.millis(), licenseMetaData.getLicense().expiryDate());
|
||||
}
|
||||
}
|
|
@ -25,7 +25,7 @@ public class LicenseRegistrationTests extends AbstractLicenseServiceTestCase {
|
|||
"testTrialLicenseRequestOnEmptyLicenseState", logger);
|
||||
setInitialState(null, licensee);
|
||||
when(discoveryNodes.isLocalNodeElectedMaster()).thenReturn(true);
|
||||
licensesService.start();
|
||||
licenseService.start();
|
||||
|
||||
ClusterState state = ClusterState.builder(new ClusterName("a")).build();
|
||||
ArgumentCaptor<ClusterStateUpdateTask> stateUpdater = ArgumentCaptor.forClass(ClusterStateUpdateTask.class);
|
||||
|
@ -34,14 +34,14 @@ public class LicenseRegistrationTests extends AbstractLicenseServiceTestCase {
|
|||
LicensesMetaData licenseMetaData = stateWithLicense.metaData().custom(LicensesMetaData.TYPE);
|
||||
assertNotNull(licenseMetaData);
|
||||
assertNotNull(licenseMetaData.getLicense());
|
||||
assertEquals(clock.millis() + LicensesService.TRIAL_LICENSE_DURATION.millis(), licenseMetaData.getLicense().expiryDate());
|
||||
assertEquals(clock.millis() + LicenseService.TRIAL_LICENSE_DURATION.millis(), licenseMetaData.getLicense().expiryDate());
|
||||
}
|
||||
|
||||
public void testNotificationOnRegistration() throws Exception {
|
||||
TestUtils.AssertingLicensee licensee = new TestUtils.AssertingLicensee(
|
||||
"testNotificationOnRegistration", logger);
|
||||
setInitialState(TestUtils.generateSignedLicense(TimeValue.timeValueHours(2)), licensee);
|
||||
licensesService.start();
|
||||
licenseService.start();
|
||||
assertThat(licensee.statuses.size(), equalTo(1));
|
||||
final LicenseState licenseState = licensee.statuses.get(0).getLicenseState();
|
||||
assertTrue(licenseState == LicenseState.ENABLED);
|
||||
|
|
|
@ -32,23 +32,23 @@ public class LicensesAcknowledgementTests extends AbstractLicenseServiceTestCase
|
|||
String[] acknowledgeMessages = new String[] {"message"};
|
||||
TestUtils.AssertingLicensee licensee = new TestUtils.AssertingLicensee(id, logger);
|
||||
setInitialState(TestUtils.generateSignedLicense("trial", TimeValue.timeValueHours(2)), licensee);
|
||||
licensesService.start();
|
||||
licenseService.start();
|
||||
licensee.setAcknowledgementMessages(acknowledgeMessages);
|
||||
// try installing a signed license
|
||||
License signedLicense = generateSignedLicense(TimeValue.timeValueHours(10));
|
||||
PutLicenseRequest putLicenseRequest = new PutLicenseRequest().license(signedLicense);
|
||||
// ensure acknowledgement message was part of the response
|
||||
licensesService.registerLicense(putLicenseRequest, new AssertingLicensesUpdateResponse(false, LicensesStatus.VALID,
|
||||
licenseService.registerLicense(putLicenseRequest, new AssertingLicensesUpdateResponse(false, LicensesStatus.VALID,
|
||||
Collections.singletonMap(id, acknowledgeMessages)));
|
||||
assertThat(licensee.acknowledgementRequested.size(), equalTo(1));
|
||||
assertThat(licensee.acknowledgementRequested.get(0).v2(), equalTo(signedLicense.operationMode()));
|
||||
assertThat(licensesService.getLicense(), not(signedLicense));
|
||||
assertThat(licenseService.getLicense(), not(signedLicense));
|
||||
|
||||
// try installing a signed license with acknowledgement
|
||||
putLicenseRequest = new PutLicenseRequest().license(signedLicense).acknowledge(true);
|
||||
// ensure license was installed and no acknowledgment message was returned
|
||||
licensee.setAcknowledgementMessages(new String[0]);
|
||||
licensesService.registerLicense(putLicenseRequest, new AssertingLicensesUpdateResponse(true, LicensesStatus.VALID,
|
||||
licenseService.registerLicense(putLicenseRequest, new AssertingLicensesUpdateResponse(true, LicensesStatus.VALID,
|
||||
Collections.<String, String[]>emptyMap()));
|
||||
verify(clusterService, times(1)).submitStateUpdateTask(any(String.class), any(ClusterStateUpdateTask.class));
|
||||
assertThat(licensee.acknowledgementRequested.size(), equalTo(1));
|
||||
|
@ -65,7 +65,7 @@ public class LicensesAcknowledgementTests extends AbstractLicenseServiceTestCase
|
|||
TestUtils.AssertingLicensee licensee2 = new TestUtils.AssertingLicensee(id2, logger);
|
||||
licensee2.setAcknowledgementMessages(acknowledgeMessages2);
|
||||
setInitialState(TestUtils.generateSignedLicense("trial", TimeValue.timeValueHours(2)), licensee1, licensee2);
|
||||
licensesService.start();
|
||||
licenseService.start();
|
||||
// try installing a signed license
|
||||
License signedLicense = generateSignedLicense(TimeValue.timeValueHours(10));
|
||||
PutLicenseRequest putLicenseRequest = new PutLicenseRequest().license(signedLicense);
|
||||
|
@ -73,21 +73,21 @@ public class LicensesAcknowledgementTests extends AbstractLicenseServiceTestCase
|
|||
final HashMap<String, String[]> expectedMessages = new HashMap<>();
|
||||
expectedMessages.put(id1, acknowledgeMessages1);
|
||||
expectedMessages.put(id2, acknowledgeMessages2);
|
||||
licensesService.registerLicense(putLicenseRequest, new AssertingLicensesUpdateResponse(false, LicensesStatus.VALID,
|
||||
licenseService.registerLicense(putLicenseRequest, new AssertingLicensesUpdateResponse(false, LicensesStatus.VALID,
|
||||
expectedMessages));
|
||||
verify(clusterService, times(0)).submitStateUpdateTask(any(String.class), any(ClusterStateUpdateTask.class));
|
||||
assertThat(licensee2.acknowledgementRequested.size(), equalTo(1));
|
||||
assertThat(licensee2.acknowledgementRequested.get(0).v2(), equalTo(signedLicense.operationMode()));
|
||||
assertThat(licensee1.acknowledgementRequested.size(), equalTo(1));
|
||||
assertThat(licensee1.acknowledgementRequested.get(0).v2(), equalTo(signedLicense.operationMode()));
|
||||
assertThat(licensesService.getLicense(), not(signedLicense));
|
||||
assertThat(licenseService.getLicense(), not(signedLicense));
|
||||
|
||||
// try installing a signed license with acknowledgement
|
||||
putLicenseRequest = new PutLicenseRequest().license(signedLicense).acknowledge(true);
|
||||
// ensure license was installed and no acknowledgment message was returned
|
||||
licensee1.setAcknowledgementMessages(new String[0]);
|
||||
licensee2.setAcknowledgementMessages(new String[0]);
|
||||
licensesService.registerLicense(putLicenseRequest, new AssertingLicensesUpdateResponse(true, LicensesStatus.VALID,
|
||||
licenseService.registerLicense(putLicenseRequest, new AssertingLicensesUpdateResponse(true, LicensesStatus.VALID,
|
||||
Collections.<String, String[]>emptyMap()));
|
||||
verify(clusterService, times(1)).submitStateUpdateTask(any(String.class), any(ClusterStateUpdateTask.class));
|
||||
}
|
||||
|
|
|
@ -55,46 +55,46 @@ public class LicensesManagerServiceTests extends ESSingleNodeTestCase {
|
|||
}
|
||||
|
||||
public void testStoreAndGetLicenses() throws Exception {
|
||||
LicensesService licensesService = getInstanceFromNode(LicensesService.class);
|
||||
LicenseService licenseService = getInstanceFromNode(LicenseService.class);
|
||||
ClusterService clusterService = getInstanceFromNode(ClusterService.class);
|
||||
License goldLicense = generateSignedLicense("gold", TimeValue.timeValueHours(1));
|
||||
TestUtils.registerAndAckSignedLicenses(licensesService, goldLicense, LicensesStatus.VALID);
|
||||
TestUtils.registerAndAckSignedLicenses(licenseService, goldLicense, LicensesStatus.VALID);
|
||||
License silverLicense = generateSignedLicense("silver", TimeValue.timeValueHours(2));
|
||||
TestUtils.registerAndAckSignedLicenses(licensesService, silverLicense, LicensesStatus.VALID);
|
||||
TestUtils.registerAndAckSignedLicenses(licenseService, silverLicense, LicensesStatus.VALID);
|
||||
License platinumLicense = generateSignedLicense("platinum", TimeValue.timeValueHours(1));
|
||||
TestUtils.registerAndAckSignedLicenses(licensesService, platinumLicense, LicensesStatus.VALID);
|
||||
TestUtils.registerAndAckSignedLicenses(licenseService, platinumLicense, LicensesStatus.VALID);
|
||||
License basicLicense = generateSignedLicense("basic", TimeValue.timeValueHours(3));
|
||||
TestUtils.registerAndAckSignedLicenses(licensesService, basicLicense, LicensesStatus.VALID);
|
||||
TestUtils.registerAndAckSignedLicenses(licenseService, basicLicense, LicensesStatus.VALID);
|
||||
LicensesMetaData licensesMetaData = clusterService.state().metaData().custom(LicensesMetaData.TYPE);
|
||||
assertThat(licensesMetaData.getLicense(), equalTo(basicLicense));
|
||||
final License getLicenses = licensesService.getLicense();
|
||||
final License getLicenses = licenseService.getLicense();
|
||||
assertThat(getLicenses, equalTo(basicLicense));
|
||||
}
|
||||
|
||||
public void testEffectiveLicenses() throws Exception {
|
||||
final LicensesService licensesService = getInstanceFromNode(LicensesService.class);
|
||||
final LicenseService licenseService = getInstanceFromNode(LicenseService.class);
|
||||
final ClusterService clusterService = getInstanceFromNode(ClusterService.class);
|
||||
License goldLicense = generateSignedLicense("gold", TimeValue.timeValueSeconds(5));
|
||||
// put gold license
|
||||
TestUtils.registerAndAckSignedLicenses(licensesService, goldLicense, LicensesStatus.VALID);
|
||||
TestUtils.registerAndAckSignedLicenses(licenseService, goldLicense, LicensesStatus.VALID);
|
||||
LicensesMetaData licensesMetaData = clusterService.state().metaData().custom(LicensesMetaData.TYPE);
|
||||
assertThat(licensesService.getLicense(licensesMetaData), equalTo(goldLicense));
|
||||
assertThat(licenseService.getLicense(licensesMetaData), equalTo(goldLicense));
|
||||
|
||||
License platinumLicense = generateSignedLicense("platinum", TimeValue.timeValueSeconds(3));
|
||||
// put platinum license
|
||||
TestUtils.registerAndAckSignedLicenses(licensesService, platinumLicense, LicensesStatus.VALID);
|
||||
TestUtils.registerAndAckSignedLicenses(licenseService, platinumLicense, LicensesStatus.VALID);
|
||||
licensesMetaData = clusterService.state().metaData().custom(LicensesMetaData.TYPE);
|
||||
assertThat(licensesService.getLicense(licensesMetaData), equalTo(platinumLicense));
|
||||
assertThat(licenseService.getLicense(licensesMetaData), equalTo(platinumLicense));
|
||||
|
||||
License basicLicense = generateSignedLicense("basic", TimeValue.timeValueSeconds(3));
|
||||
// put basic license
|
||||
TestUtils.registerAndAckSignedLicenses(licensesService, basicLicense, LicensesStatus.VALID);
|
||||
TestUtils.registerAndAckSignedLicenses(licenseService, basicLicense, LicensesStatus.VALID);
|
||||
licensesMetaData = clusterService.state().metaData().custom(LicensesMetaData.TYPE);
|
||||
assertThat(licensesService.getLicense(licensesMetaData), equalTo(basicLicense));
|
||||
assertThat(licenseService.getLicense(licensesMetaData), equalTo(basicLicense));
|
||||
}
|
||||
|
||||
public void testInvalidLicenseStorage() throws Exception {
|
||||
LicensesService licensesService = getInstanceFromNode(LicensesService.class);
|
||||
LicenseService licenseService = getInstanceFromNode(LicenseService.class);
|
||||
ClusterService clusterService = getInstanceFromNode(ClusterService.class);
|
||||
License signedLicense = generateSignedLicense(TimeValue.timeValueMinutes(2));
|
||||
|
||||
|
@ -105,7 +105,7 @@ public class LicensesManagerServiceTests extends ESSingleNodeTestCase {
|
|||
.validate()
|
||||
.build();
|
||||
|
||||
TestUtils.registerAndAckSignedLicenses(licensesService, tamperedLicense, LicensesStatus.INVALID);
|
||||
TestUtils.registerAndAckSignedLicenses(licenseService, tamperedLicense, LicensesStatus.INVALID);
|
||||
|
||||
// ensure that the invalid license never made it to cluster state
|
||||
LicensesMetaData licensesMetaData = clusterService.state().metaData().custom(LicensesMetaData.TYPE);
|
||||
|
@ -113,25 +113,25 @@ public class LicensesManagerServiceTests extends ESSingleNodeTestCase {
|
|||
}
|
||||
|
||||
public void testRemoveLicenses() throws Exception {
|
||||
LicensesService licensesService = getInstanceFromNode(LicensesService.class);
|
||||
LicenseService licenseService = getInstanceFromNode(LicenseService.class);
|
||||
ClusterService clusterService = getInstanceFromNode(ClusterService.class);
|
||||
|
||||
// generate signed licenses
|
||||
License license = generateSignedLicense(TimeValue.timeValueHours(1));
|
||||
TestUtils.registerAndAckSignedLicenses(licensesService, license, LicensesStatus.VALID);
|
||||
TestUtils.registerAndAckSignedLicenses(licenseService, license, LicensesStatus.VALID);
|
||||
LicensesMetaData licensesMetaData = clusterService.state().metaData().custom(LicensesMetaData.TYPE);
|
||||
assertThat(licensesMetaData.getLicense(), not(LicensesMetaData.LICENSE_TOMBSTONE));
|
||||
|
||||
// remove signed licenses
|
||||
removeAndAckSignedLicenses(licensesService);
|
||||
removeAndAckSignedLicenses(licenseService);
|
||||
licensesMetaData = clusterService.state().metaData().custom(LicensesMetaData.TYPE);
|
||||
assertThat(licensesMetaData.getLicense(), equalTo(LicensesMetaData.LICENSE_TOMBSTONE));
|
||||
}
|
||||
|
||||
private void removeAndAckSignedLicenses(final LicensesService licensesService) {
|
||||
private void removeAndAckSignedLicenses(final LicenseService licenseService) {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final AtomicBoolean success = new AtomicBoolean(false);
|
||||
licensesService.removeLicense(new DeleteLicenseRequest(), new ActionListener<ClusterStateUpdateResponse>() {
|
||||
licenseService.removeLicense(new DeleteLicenseRequest(), new ActionListener<ClusterStateUpdateResponse>() {
|
||||
@Override
|
||||
public void onResponse(ClusterStateUpdateResponse clusterStateUpdateResponse) {
|
||||
if (clusterStateUpdateResponse.isAcknowledged()) {
|
||||
|
|
|
@ -26,19 +26,19 @@ public class LicensesNotificationTests extends AbstractLicenseServiceTestCase {
|
|||
assertingLicensees[i] = new AssertingLicensee("testLicenseNotification" + i, logger);
|
||||
}
|
||||
setInitialState(license, assertingLicensees);
|
||||
licensesService.start();
|
||||
licenseService.start();
|
||||
for (int i = 0; i < assertingLicensees.length; i++) {
|
||||
assertLicenseStates(assertingLicensees[i], LicenseState.ENABLED);
|
||||
}
|
||||
clock.fastForward(TimeValue.timeValueMillis(license.expiryDate() - clock.millis()));
|
||||
final LicensesMetaData licensesMetaData = new LicensesMetaData(license);
|
||||
licensesService.onUpdate(licensesMetaData);
|
||||
licenseService.onUpdate(licensesMetaData);
|
||||
for (AssertingLicensee assertingLicensee : assertingLicensees) {
|
||||
assertLicenseStates(assertingLicensee, LicenseState.ENABLED, LicenseState.GRACE_PERIOD);
|
||||
}
|
||||
clock.fastForward(TimeValue.timeValueMillis((license.expiryDate() +
|
||||
LicenseState.GRACE_PERIOD_DURATION.getMillis()) - clock.millis()));
|
||||
licensesService.onUpdate(licensesMetaData);
|
||||
licenseService.onUpdate(licensesMetaData);
|
||||
for (AssertingLicensee assertingLicensee : assertingLicensees) {
|
||||
assertLicenseStates(assertingLicensee, LicenseState.ENABLED, LicenseState.GRACE_PERIOD, LicenseState.DISABLED);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class LicensesNotificationTests extends AbstractLicenseServiceTestCase {
|
|||
final License newLicense = TestUtils.generateSignedLicense(TimeValue.timeValueHours(2));
|
||||
clock.fastForward(TimeValue.timeValueHours(1));
|
||||
LicensesMetaData licensesMetaData1 = new LicensesMetaData(newLicense);
|
||||
licensesService.onUpdate(licensesMetaData1);
|
||||
licenseService.onUpdate(licensesMetaData1);
|
||||
for (AssertingLicensee assertingLicensee : assertingLicensees) {
|
||||
assertLicenseStates(assertingLicensee, LicenseState.ENABLED, LicenseState.GRACE_PERIOD, LicenseState.DISABLED,
|
||||
LicenseState.ENABLED);
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.elasticsearch.cluster.service.ClusterService;
|
|||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.plugin.core.LicenseUtils;
|
||||
import org.elasticsearch.license.plugin.core.LicensesService;
|
||||
import org.elasticsearch.license.plugin.core.LicenseService;
|
||||
import org.elasticsearch.xpack.monitoring.MonitoringLicensee;
|
||||
import org.elasticsearch.xpack.monitoring.MonitoringSettings;
|
||||
import org.elasticsearch.xpack.monitoring.agent.collector.AbstractCollector;
|
||||
|
@ -40,16 +40,16 @@ public class ClusterStatsCollector extends AbstractCollector {
|
|||
|
||||
public static final String NAME = "cluster-stats-collector";
|
||||
|
||||
private final LicensesService licensesService;
|
||||
private final LicenseService licenseService;
|
||||
private final Client client;
|
||||
|
||||
@Inject
|
||||
public ClusterStatsCollector(Settings settings, ClusterService clusterService,
|
||||
MonitoringSettings monitoringSettings, MonitoringLicensee licensee, InternalClient client,
|
||||
LicensesService licensesService) {
|
||||
LicenseService licenseService) {
|
||||
super(settings, NAME, clusterService, monitoringSettings, licensee);
|
||||
this.client = client;
|
||||
this.licensesService = licensesService;
|
||||
this.licenseService = licenseService;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -85,7 +85,7 @@ public class ClusterStatsCollector extends AbstractCollector {
|
|||
clusterInfoDoc.setSourceNode(sourceNode);
|
||||
clusterInfoDoc.setClusterName(clusterService.getClusterName().value());
|
||||
clusterInfoDoc.setVersion(Version.CURRENT.toString());
|
||||
clusterInfoDoc.setLicense(licensesService.getLicense());
|
||||
clusterInfoDoc.setLicense(licenseService.getLicense());
|
||||
clusterInfoDoc.setClusterStats(clusterStats);
|
||||
results.add(clusterInfoDoc);
|
||||
|
||||
|
|
|
@ -25,9 +25,9 @@ import org.elasticsearch.common.unit.TimeValue;
|
|||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.license.core.License;
|
||||
import org.elasticsearch.license.plugin.Licensing;
|
||||
import org.elasticsearch.license.plugin.core.LicenseService;
|
||||
import org.elasticsearch.license.plugin.core.LicenseState;
|
||||
import org.elasticsearch.license.plugin.core.Licensee;
|
||||
import org.elasticsearch.license.plugin.core.LicensesService;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.rest.RestHandler;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
|
@ -192,7 +192,7 @@ public abstract class AbstractCollectorTestCase extends MonitoringIntegTestCase
|
|||
|
||||
@Override
|
||||
public Collection<Module> nodeModules() {
|
||||
return Collections.singletonList(b -> b.bind(LicensesService.class).to(LicenseServiceForCollectors.class));
|
||||
return Collections.singletonList(b -> b.bind(LicenseService.class).to(LicenseServiceForCollectors.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -202,9 +202,9 @@ public abstract class AbstractCollectorTestCase extends MonitoringIntegTestCase
|
|||
WatcherLicensee watcherLicensee = new WatcherLicensee(settings);
|
||||
MonitoringLicensee monitoringLicensee = new MonitoringLicensee(settings);
|
||||
GraphLicensee graphLicensee = new GraphLicensee(settings);
|
||||
LicensesService licensesService = new LicenseServiceForCollectors(settings, environment,
|
||||
LicenseService licenseService = new LicenseServiceForCollectors(settings, environment,
|
||||
resourceWatcherService, Arrays.asList(watcherLicensee, monitoringLicensee, graphLicensee));
|
||||
return Arrays.asList(licensesService, watcherLicensee, monitoringLicensee, graphLicensee);
|
||||
return Arrays.asList(licenseService, watcherLicensee, monitoringLicensee, graphLicensee);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -226,7 +226,7 @@ public abstract class AbstractCollectorTestCase extends MonitoringIntegTestCase
|
|||
}
|
||||
}
|
||||
|
||||
public static class LicenseServiceForCollectors extends LicensesService {
|
||||
public static class LicenseServiceForCollectors extends LicenseService {
|
||||
|
||||
private final List<Licensee> licensees;
|
||||
private volatile License license;
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.apache.lucene.util.LuceneTestCase.BadApple;
|
|||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.plugin.core.LicensesService;
|
||||
import org.elasticsearch.license.plugin.core.LicenseService;
|
||||
import org.elasticsearch.xpack.monitoring.MonitoredSystem;
|
||||
import org.elasticsearch.xpack.monitoring.MonitoringLicensee;
|
||||
import org.elasticsearch.xpack.monitoring.MonitoringSettings;
|
||||
|
@ -133,7 +133,7 @@ public class ClusterStatsCollectorTests extends AbstractCollectorTestCase {
|
|||
internalCluster().getInstance(MonitoringSettings.class, nodeId),
|
||||
internalCluster().getInstance(MonitoringLicensee.class, nodeId),
|
||||
securedClient(nodeId),
|
||||
internalCluster().getInstance(LicensesService.class, nodeId));
|
||||
internalCluster().getInstance(LicenseService.class, nodeId));
|
||||
}
|
||||
|
||||
private void assertCanCollect(AbstractCollector collector, Class<?>... classes) {
|
||||
|
|
|
@ -14,10 +14,9 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.license.core.License;
|
||||
import org.elasticsearch.license.plugin.Licensing;
|
||||
import org.elasticsearch.license.plugin.core.AbstractLicenseeComponent;
|
||||
import org.elasticsearch.license.plugin.core.LicenseService;
|
||||
import org.elasticsearch.license.plugin.core.LicenseState;
|
||||
import org.elasticsearch.license.plugin.core.Licensee;
|
||||
import org.elasticsearch.license.plugin.core.LicensesService;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.rest.RestHandler;
|
||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||
|
@ -31,7 +30,6 @@ import org.elasticsearch.xpack.support.clock.Clock;
|
|||
import org.elasticsearch.xpack.watcher.WatcherLicensee;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -96,7 +94,7 @@ public class LicenseIntegrationTests extends MonitoringIntegTestCase {
|
|||
|
||||
@Override
|
||||
public Collection<Module> nodeModules() {
|
||||
return Collections.singletonList(b -> b.bind(LicensesService.class).to(MockLicenseService.class));
|
||||
return Collections.singletonList(b -> b.bind(LicenseService.class).to(MockLicenseService.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -106,9 +104,9 @@ public class LicenseIntegrationTests extends MonitoringIntegTestCase {
|
|||
WatcherLicensee watcherLicensee = new WatcherLicensee(settings);
|
||||
MonitoringLicensee monitoringLicensee = new MonitoringLicensee(settings);
|
||||
GraphLicensee graphLicensee = new GraphLicensee(settings);
|
||||
LicensesService licensesService = new MockLicenseService(settings, environment, resourceWatcherService,
|
||||
LicenseService licenseService = new MockLicenseService(settings, environment, resourceWatcherService,
|
||||
Arrays.asList(watcherLicensee, monitoringLicensee, graphLicensee));
|
||||
return Arrays.asList(licensesService, watcherLicensee, monitoringLicensee, graphLicensee);
|
||||
return Arrays.asList(licenseService, watcherLicensee, monitoringLicensee, graphLicensee);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -122,7 +120,7 @@ public class LicenseIntegrationTests extends MonitoringIntegTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public static class MockLicenseService extends LicensesService {
|
||||
public static class MockLicenseService extends LicenseService {
|
||||
|
||||
private final List<Licensee> licensees;
|
||||
|
||||
|
|
|
@ -34,9 +34,9 @@ import org.elasticsearch.common.util.concurrent.ThreadContext;
|
|||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.license.core.License.OperationMode;
|
||||
import org.elasticsearch.license.plugin.Licensing;
|
||||
import org.elasticsearch.license.plugin.core.LicenseService;
|
||||
import org.elasticsearch.license.plugin.core.LicenseState;
|
||||
import org.elasticsearch.license.plugin.core.Licensee;
|
||||
import org.elasticsearch.license.plugin.core.LicensesService;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.rest.RestHandler;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
|
@ -238,7 +238,7 @@ public class LicensingTests extends SecurityIntegTestCase {
|
|||
}
|
||||
|
||||
public static void disableLicensing(OperationMode operationMode) {
|
||||
for (TestLicensesService service : internalCluster().getInstances(TestLicensesService.class)) {
|
||||
for (TestLicenseService service : internalCluster().getInstances(TestLicenseService.class)) {
|
||||
service.disable(operationMode);
|
||||
}
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ public class LicensingTests extends SecurityIntegTestCase {
|
|||
}
|
||||
|
||||
public static void enableLicensing(OperationMode operationMode) {
|
||||
for (TestLicensesService service : internalCluster().getInstances(TestLicensesService.class)) {
|
||||
for (TestLicenseService service : internalCluster().getInstances(TestLicenseService.class)) {
|
||||
service.enable(operationMode);
|
||||
}
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ public class LicensingTests extends SecurityIntegTestCase {
|
|||
|
||||
@Override
|
||||
public Collection<Module> nodeModules() {
|
||||
return Collections.singletonList(b -> b.bind(LicensesService.class).to(TestLicensesService.class));
|
||||
return Collections.singletonList(b -> b.bind(LicenseService.class).to(TestLicenseService.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -268,7 +268,7 @@ public class LicensingTests extends SecurityIntegTestCase {
|
|||
WatcherLicensee watcherLicensee = new WatcherLicensee(settings);
|
||||
MonitoringLicensee monitoringLicensee = new MonitoringLicensee(settings);
|
||||
GraphLicensee graphLicensee = new GraphLicensee(settings);
|
||||
TestLicensesService licensesService = new TestLicensesService(settings, environment, resourceWatcherService,
|
||||
TestLicenseService licensesService = new TestLicenseService(settings, environment, resourceWatcherService,
|
||||
Arrays.asList(securityLicensee, watcherLicensee, monitoringLicensee, graphLicensee));
|
||||
return Arrays.asList(securityLicensee, licensesService, watcherLicensee, monitoringLicensee,
|
||||
graphLicensee, securityLicenseState);
|
||||
|
@ -297,12 +297,12 @@ public class LicensingTests extends SecurityIntegTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public static class TestLicensesService extends LicensesService {
|
||||
public static class TestLicenseService extends LicenseService {
|
||||
|
||||
private final List<Licensee> licensees;
|
||||
|
||||
public TestLicensesService(Settings settings, Environment env, ResourceWatcherService resourceWatcherService,
|
||||
List<Licensee> licensees) {
|
||||
public TestLicenseService(Settings settings, Environment env, ResourceWatcherService resourceWatcherService,
|
||||
List<Licensee> licensees) {
|
||||
super(settings, null, null, env, resourceWatcherService, Collections.emptyList());
|
||||
this.licensees = licensees;
|
||||
enable(OperationMode.BASIC);
|
||||
|
|
|
@ -169,7 +169,7 @@ public class XPackPlugin extends Plugin implements ScriptPlugin, ActionPlugin, I
|
|||
|
||||
if (transportClientMode == false) {
|
||||
modules.add(new TextTemplateModule());
|
||||
// Note: this only exists so LicensesService subclasses can be bound in mock tests
|
||||
// Note: this only exists so LicenseService subclasses can be bound in mock tests
|
||||
modules.addAll(licensing.nodeModules());
|
||||
}
|
||||
return modules;
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
|||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.core.License;
|
||||
import org.elasticsearch.license.plugin.core.LicensesService;
|
||||
import org.elasticsearch.license.plugin.core.LicenseService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.xpack.XPackBuild;
|
||||
|
@ -27,16 +27,16 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
public class TransportXPackInfoAction extends HandledTransportAction<XPackInfoRequest, XPackInfoResponse> {
|
||||
|
||||
private final LicensesService licensesService;
|
||||
private final LicenseService licenseService;
|
||||
private final Set<XPackFeatureSet> featureSets;
|
||||
|
||||
@Inject
|
||||
public TransportXPackInfoAction(Settings settings, ThreadPool threadPool, TransportService transportService,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver,
|
||||
LicensesService licensesService, Set<XPackFeatureSet> featureSets) {
|
||||
LicenseService licenseService, Set<XPackFeatureSet> featureSets) {
|
||||
super(settings, XPackInfoAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver,
|
||||
XPackInfoRequest::new);
|
||||
this.licensesService = licensesService;
|
||||
this.licenseService = licenseService;
|
||||
this.featureSets = featureSets;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class TransportXPackInfoAction extends HandledTransportAction<XPackInfoRe
|
|||
|
||||
LicenseInfo licenseInfo = null;
|
||||
if (request.getCategories().contains(XPackInfoRequest.Category.LICENSE)) {
|
||||
License license = licensesService.getLicense();
|
||||
License license = licenseService.getLicense();
|
||||
if (license != null) {
|
||||
licenseInfo = new LicenseInfo(license);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.elasticsearch.action.support.ActionFilters;
|
|||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.core.License;
|
||||
import org.elasticsearch.license.plugin.core.LicensesService;
|
||||
import org.elasticsearch.license.plugin.core.LicenseService;
|
||||
import org.elasticsearch.xpack.security.user.AnonymousUser;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
|
@ -57,7 +57,7 @@ public class TransportXPackInfoActionTests extends ESTestCase {
|
|||
|
||||
public void testDoExecute() throws Exception {
|
||||
|
||||
LicensesService licensesService = mock(LicensesService.class);
|
||||
LicenseService licenseService = mock(LicenseService.class);
|
||||
|
||||
final Set<XPackFeatureSet> featureSets = new HashSet<>();
|
||||
int featureSetCount = randomIntBetween(0, 5);
|
||||
|
@ -72,7 +72,7 @@ public class TransportXPackInfoActionTests extends ESTestCase {
|
|||
|
||||
TransportXPackInfoAction action = new TransportXPackInfoAction(Settings.EMPTY, mock(ThreadPool.class),
|
||||
mock(TransportService.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class),
|
||||
licensesService, featureSets);
|
||||
licenseService, featureSets);
|
||||
|
||||
License license = mock(License.class);
|
||||
long expiryDate = randomLong();
|
||||
|
@ -85,7 +85,7 @@ public class TransportXPackInfoActionTests extends ESTestCase {
|
|||
when(license.operationMode()).thenReturn(mode);
|
||||
String uid = randomAsciiOfLength(30);
|
||||
when(license.uid()).thenReturn(uid);
|
||||
when(licensesService.getLicense()).thenReturn(license);
|
||||
when(licenseService.getLicense()).thenReturn(license);
|
||||
|
||||
XPackInfoRequest request = new XPackInfoRequest();
|
||||
request.setVerbose(randomBoolean());
|
||||
|
|
Loading…
Reference in New Issue