Merge pull request elastic/elasticsearch#2902 from rjernst/license_state_removal
Internal: Removed LicenseState enum Original commit: elastic/x-pack-elasticsearch@13abacbb78
This commit is contained in:
commit
d734d483c5
|
@ -9,7 +9,6 @@ import org.elasticsearch.common.Strings;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.core.License.OperationMode;
|
||||
import org.elasticsearch.license.plugin.core.AbstractLicenseeComponent;
|
||||
import org.elasticsearch.license.plugin.core.LicenseState;
|
||||
|
||||
public class GraphLicensee extends AbstractLicenseeComponent {
|
||||
|
||||
|
@ -60,6 +59,6 @@ public class GraphLicensee extends AbstractLicenseeComponent {
|
|||
|
||||
boolean licensed = operationMode == OperationMode.TRIAL || operationMode == OperationMode.PLATINUM;
|
||||
|
||||
return licensed && localStatus.getLicenseState() != LicenseState.DISABLED;
|
||||
return licensed && localStatus.isActive();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,43 +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.plugin.core;
|
||||
|
||||
import org.elasticsearch.license.core.License;
|
||||
import org.elasticsearch.xpack.scheduler.SchedulerEngine;
|
||||
|
||||
|
||||
public class LicenseSchedule implements SchedulerEngine.Schedule {
|
||||
|
||||
private final License license;
|
||||
|
||||
LicenseSchedule(License license) {
|
||||
this.license = license;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long nextScheduledTimeAfter(long startTime, long time) {
|
||||
long nextScheduledTime = -1;
|
||||
switch (LicenseState.resolve(license, time)) {
|
||||
case ENABLED:
|
||||
nextScheduledTime = license.expiryDate();
|
||||
break;
|
||||
case GRACE_PERIOD:
|
||||
nextScheduledTime = license.expiryDate() + LicenseState.GRACE_PERIOD_DURATION.getMillis();
|
||||
break;
|
||||
case DISABLED:
|
||||
if (license.issueDate() > time) {
|
||||
// when we encounter a license with a future issue date
|
||||
// which can happen with autogenerated license,
|
||||
// we want to schedule a notification on the license issue date
|
||||
// so the license is notificed once it is valid
|
||||
// see https://github.com/elastic/x-plugins/issues/983
|
||||
nextScheduledTime = license.issueDate();
|
||||
}
|
||||
break;
|
||||
}
|
||||
return nextScheduledTime;
|
||||
}
|
||||
}
|
|
@ -62,6 +62,11 @@ public class LicenseService extends AbstractLifecycleComponent implements Cluste
|
|||
// pkg private for tests
|
||||
static final TimeValue TRIAL_LICENSE_DURATION = TimeValue.timeValueHours(30 * 24);
|
||||
|
||||
/**
|
||||
* Duration of grace period after a license has expired
|
||||
*/
|
||||
public static final TimeValue GRACE_PERIOD_DURATION = days(7);
|
||||
|
||||
private final ClusterService clusterService;
|
||||
|
||||
/**
|
||||
|
@ -310,12 +315,15 @@ public class LicenseService extends AbstractLifecycleComponent implements Cluste
|
|||
});
|
||||
}
|
||||
|
||||
public Licensee.Status licenseeStatus() {
|
||||
final License license = getLicense();
|
||||
public Licensee.Status licenseeStatus(License license) {
|
||||
if (license == null) {
|
||||
return Licensee.Status.MISSING;
|
||||
return new Licensee.Status(License.OperationMode.MISSING, false);
|
||||
}
|
||||
return new Licensee.Status(license.operationMode(), LicenseState.resolve(license, clock.millis()));
|
||||
long time = clock.millis();
|
||||
boolean active = time >= license.issueDate() &&
|
||||
time < license.expiryDate() + GRACE_PERIOD_DURATION.getMillis();
|
||||
|
||||
return new Licensee.Status(license.operationMode(), active);
|
||||
}
|
||||
|
||||
public License getLicense() {
|
||||
|
@ -433,18 +441,22 @@ public class LicenseService extends AbstractLifecycleComponent implements Cluste
|
|||
}
|
||||
if (license != null) {
|
||||
logger.debug("notifying [{}] listeners", registeredLicensees.size());
|
||||
final LicenseState licenseState = LicenseState.resolve(license, clock.millis());
|
||||
Licensee.Status status = new Licensee.Status(license.operationMode(), licenseState);
|
||||
long time = clock.millis();
|
||||
boolean active = time >= license.issueDate() &&
|
||||
time < license.expiryDate() + GRACE_PERIOD_DURATION.getMillis();
|
||||
|
||||
Licensee.Status status = new Licensee.Status(license.operationMode(), active);
|
||||
for (InternalLicensee licensee : registeredLicensees) {
|
||||
licensee.onChange(status);
|
||||
}
|
||||
switch (status.getLicenseState()) {
|
||||
case ENABLED:
|
||||
logger.debug("license [{}] - valid", license.uid()); break;
|
||||
case GRACE_PERIOD:
|
||||
logger.warn("license [{}] - grace", license.uid()); break;
|
||||
case DISABLED:
|
||||
logger.warn("license [{}] - expired", license.uid()); break;
|
||||
if (active) {
|
||||
if (time < license.expiryDate()) {
|
||||
logger.debug("license [{}] - valid", license.uid());
|
||||
} else {
|
||||
logger.warn("license [{}] - grace", license.uid());
|
||||
}
|
||||
} else {
|
||||
logger.warn("license [{}] - expired", license.uid());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -464,7 +476,7 @@ public class LicenseService extends AbstractLifecycleComponent implements Cluste
|
|||
if (license.equals(previousLicense) == false) {
|
||||
currentLicense.set(license);
|
||||
license.setOperationModeFileWatcher(operationModeFileWatcher);
|
||||
scheduler.add(new SchedulerEngine.Job(LICENSE_JOB, new LicenseSchedule(license)));
|
||||
scheduler.add(new SchedulerEngine.Job(LICENSE_JOB, nextLicenseCheck(license)));
|
||||
for (ExpirationCallback expirationCallback : expirationCallbacks) {
|
||||
scheduler.add(new SchedulerEngine.Job(expirationCallback.getId(),
|
||||
(startTime, now) ->
|
||||
|
@ -479,6 +491,25 @@ public class LicenseService extends AbstractLifecycleComponent implements Cluste
|
|||
}
|
||||
}
|
||||
|
||||
// pkg private for tests
|
||||
static SchedulerEngine.Schedule nextLicenseCheck(License license) {
|
||||
return (startTime, time) -> {
|
||||
if (time < license.issueDate()) {
|
||||
// when we encounter a license with a future issue date
|
||||
// which can happen with autogenerated license,
|
||||
// we want to schedule a notification on the license issue date
|
||||
// so the license is notificed once it is valid
|
||||
// see https://github.com/elastic/x-plugins/issues/983
|
||||
return license.issueDate();
|
||||
} else if (time < license.expiryDate()) {
|
||||
return license.expiryDate();
|
||||
} else if (time < license.expiryDate() + GRACE_PERIOD_DURATION.getMillis()) {
|
||||
return license.expiryDate() + GRACE_PERIOD_DURATION.getMillis();
|
||||
}
|
||||
return -1; // license is expired, no need to check again
|
||||
};
|
||||
}
|
||||
|
||||
private void initLicensee(Licensee licensee) {
|
||||
logger.debug("initializing licensee [{}]", licensee.id());
|
||||
final ClusterState clusterState = clusterService.state();
|
||||
|
|
|
@ -1,68 +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.plugin.core;
|
||||
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.license.core.License;
|
||||
|
||||
import static org.elasticsearch.license.plugin.core.LicenseService.days;
|
||||
|
||||
/**
|
||||
* States of a registered licensee
|
||||
* based on the current license
|
||||
*/
|
||||
public enum LicenseState {
|
||||
|
||||
/**
|
||||
* Active license is valid.
|
||||
*
|
||||
* When license expires
|
||||
* changes to {@link #GRACE_PERIOD}
|
||||
*/
|
||||
ENABLED,
|
||||
|
||||
/**
|
||||
* Active license expired
|
||||
* but grace period has not.
|
||||
*
|
||||
* When grace period expires
|
||||
* changes to {@link #DISABLED}.
|
||||
* When valid license is installed
|
||||
* changes back to {@link #ENABLED}
|
||||
*/
|
||||
GRACE_PERIOD,
|
||||
|
||||
/**
|
||||
* Grace period for active license
|
||||
* expired.
|
||||
*
|
||||
* When a valid license is installed
|
||||
* changes to {@link #ENABLED}, otherwise
|
||||
* remains unchanged
|
||||
*/
|
||||
DISABLED;
|
||||
|
||||
/**
|
||||
* Duration of grace period after a license has expired
|
||||
*/
|
||||
public static final TimeValue GRACE_PERIOD_DURATION = days(7);
|
||||
|
||||
public static LicenseState resolve(final License license, long time) {
|
||||
if (license == null) {
|
||||
return DISABLED;
|
||||
}
|
||||
if (license.issueDate() > time) {
|
||||
return DISABLED;
|
||||
}
|
||||
if (license.expiryDate() > time) {
|
||||
return ENABLED;
|
||||
}
|
||||
if ((license.expiryDate() + GRACE_PERIOD_DURATION.getMillis()) > time) {
|
||||
return GRACE_PERIOD;
|
||||
}
|
||||
return DISABLED;
|
||||
}
|
||||
}
|
|
@ -44,69 +44,60 @@ public interface Licensee {
|
|||
* whenever checking different parts of the {@code Status}:
|
||||
* <pre>
|
||||
* Status status = this.status;
|
||||
* return status.getLicenseState() != LicenseState.DISABLED &&
|
||||
* (status.getMode() == OperationMode.TRAIL || status.getMode == OperationMode.PLATINUM);
|
||||
* return status.isActive() &&
|
||||
* (status.getMode() == OperationMode.TRIAL || status.getMode == OperationMode.PLATINUM);
|
||||
* </pre>
|
||||
* Otherwise the license has the potential to change in-between both checks.
|
||||
*/
|
||||
class Status {
|
||||
|
||||
public static Status ENABLED = new Status(OperationMode.TRIAL, LicenseState.ENABLED);
|
||||
public static Status MISSING = new Status(OperationMode.MISSING, LicenseState.DISABLED);
|
||||
public static Status ENABLED = new Status(OperationMode.TRIAL, true);
|
||||
public static Status MISSING = new Status(OperationMode.MISSING, false);
|
||||
|
||||
private final OperationMode mode;
|
||||
private final LicenseState licenseState;
|
||||
private final boolean active;
|
||||
|
||||
public Status(OperationMode mode, LicenseState licenseState) {
|
||||
public Status(OperationMode mode, boolean active) {
|
||||
this.mode = mode;
|
||||
this.licenseState = licenseState;
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the operation mode of the license
|
||||
* responsible for the current <code>licenseState</code>
|
||||
* <p>
|
||||
* Note: Knowing the mode does not indicate whether the {@link #getLicenseState() state} is disabled. If that matters (e.g.,
|
||||
* disabling services when a license becomes disabled), then you should check it as well!
|
||||
* Note: Knowing the mode does not indicate whether the license is active. If that matters (e.g.,
|
||||
* disabling services when a license becomes disabled), then check {@link #isActive()}.
|
||||
*/
|
||||
public OperationMode getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* When a license is active, the state is
|
||||
* {@link LicenseState#ENABLED}, upon license expiry
|
||||
* the state changes to {@link LicenseState#GRACE_PERIOD}
|
||||
* and after the grace period has ended the state changes
|
||||
* to {@link LicenseState#DISABLED}
|
||||
*/
|
||||
public LicenseState getLicenseState() {
|
||||
return licenseState;
|
||||
/** Returns true if the license is within the issue date and grace period, or false otherwise */
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Status status = (Status) o;
|
||||
return Objects.equals(mode, status.mode) && Objects.equals(licenseState, status.licenseState);
|
||||
return active == status.active &&
|
||||
mode == status.mode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(mode, licenseState);
|
||||
return Objects.hash(mode, active);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
switch (licenseState) {
|
||||
case DISABLED:
|
||||
return "disabled " + mode.name().toLowerCase(Locale.ROOT);
|
||||
case GRACE_PERIOD:
|
||||
return mode.name().toLowerCase(Locale.ROOT) + " grace period";
|
||||
default:
|
||||
return mode.name().toLowerCase(Locale.ROOT);
|
||||
if (active) {
|
||||
return mode.name().toLowerCase(Locale.ROOT);
|
||||
} else {
|
||||
return "disabled " + mode.name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ 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.plugins.Plugin;
|
||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||
import org.elasticsearch.xpack.MockNetty3Plugin;
|
||||
|
@ -124,40 +123,40 @@ public class LicensesServiceClusterTests extends AbstractLicensesIntegrationTest
|
|||
wipeAllLicenses();
|
||||
internalCluster().startNode();
|
||||
ensureGreen();
|
||||
assertLicenseState(LicenseState.ENABLED);
|
||||
assertLicenseState(true);
|
||||
logger.info("--> restart node");
|
||||
internalCluster().fullRestart();
|
||||
ensureYellow();
|
||||
logger.info("--> await node for enabled");
|
||||
assertLicenseState(LicenseState.ENABLED);
|
||||
assertLicenseState(true);
|
||||
}
|
||||
|
||||
public void testClusterRestartWhileGrace() throws Exception {
|
||||
wipeAllLicenses();
|
||||
internalCluster().startNode();
|
||||
assertLicenseState(LicenseState.ENABLED);
|
||||
assertLicenseState(true);
|
||||
putLicense(TestUtils.generateSignedLicense(TimeValue.timeValueMillis(0)));
|
||||
ensureGreen();
|
||||
assertLicenseState(LicenseState.GRACE_PERIOD);
|
||||
assertLicenseState(true);
|
||||
logger.info("--> restart node");
|
||||
internalCluster().fullRestart();
|
||||
ensureYellow();
|
||||
logger.info("--> await node for grace_period");
|
||||
assertLicenseState(LicenseState.GRACE_PERIOD);
|
||||
assertLicenseState(true);
|
||||
}
|
||||
|
||||
public void testClusterRestartWhileExpired() throws Exception {
|
||||
wipeAllLicenses();
|
||||
internalCluster().startNode();
|
||||
ensureGreen();
|
||||
assertLicenseState(LicenseState.ENABLED);
|
||||
putLicense(TestUtils.generateExpiredLicense(System.currentTimeMillis() - LicenseState.GRACE_PERIOD_DURATION.getMillis()));
|
||||
assertLicenseState(LicenseState.DISABLED);
|
||||
assertLicenseState(true);
|
||||
putLicense(TestUtils.generateExpiredLicense(System.currentTimeMillis() - LicenseService.GRACE_PERIOD_DURATION.getMillis()));
|
||||
assertLicenseState(false);
|
||||
logger.info("--> restart node");
|
||||
internalCluster().fullRestart();
|
||||
ensureYellow();
|
||||
logger.info("--> await node for disabled");
|
||||
assertLicenseState(LicenseState.DISABLED);
|
||||
assertLicenseState(false);
|
||||
}
|
||||
|
||||
public void testClusterNotRecovered() throws Exception {
|
||||
|
@ -165,13 +164,13 @@ public class LicensesServiceClusterTests extends AbstractLicensesIntegrationTest
|
|||
internalCluster().startNode(nodeSettingsBuilder(0).put("discovery.zen.minimum_master_nodes", 2).put("node.master", true));
|
||||
logger.info("--> start second master out of two [recovered state]");
|
||||
internalCluster().startNode(nodeSettingsBuilder(1).put("discovery.zen.minimum_master_nodes", 2).put("node.master", true));
|
||||
assertLicenseState(LicenseState.ENABLED);
|
||||
assertLicenseState(true);
|
||||
}
|
||||
|
||||
private void assertLicenseState(LicenseState state) throws InterruptedException {
|
||||
private void assertLicenseState(boolean active) throws InterruptedException {
|
||||
boolean success = awaitBusy(() -> {
|
||||
for (LicenseService service : internalCluster().getDataNodeInstances(LicenseService.class)) {
|
||||
if (service.licenseeStatus().getLicenseState() == state) {
|
||||
if (service.licenseeStatus(service.getLicense()).isActive() == active) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -183,7 +182,7 @@ public class LicensesServiceClusterTests extends AbstractLicensesIntegrationTest
|
|||
private void assertOperationMode(License.OperationMode operationMode) throws InterruptedException {
|
||||
boolean success = awaitBusy(() -> {
|
||||
for (LicenseService service : internalCluster().getDataNodeInstances(LicenseService.class)) {
|
||||
if (service.licenseeStatus().getMode() == operationMode) {
|
||||
if (service.licenseeStatus(service.getLicense()).getMode() == operationMode) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,15 +122,6 @@ public abstract class AbstractLicenseeTestCase extends ESTestCase {
|
|||
return randomValueOtherThan(mode, AbstractLicenseeTestCase::randomMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Randomly get {@link LicenseState#ENABLED} or {@link LicenseState#GRACE_PERIOD}.
|
||||
*
|
||||
* @return Never {@code null}.
|
||||
*/
|
||||
public static LicenseState randomEnabledOrGracePeriodState() {
|
||||
return randomFrom(LicenseState.ENABLED, LicenseState.GRACE_PERIOD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a random value from the {@code values} that passes {@code filter}.
|
||||
*
|
||||
|
@ -163,10 +154,10 @@ public abstract class AbstractLicenseeTestCase extends ESTestCase {
|
|||
}
|
||||
|
||||
public void disable(Licensee licensee) {
|
||||
licensee.onChange(new Licensee.Status(operationMode, LicenseState.DISABLED));
|
||||
licensee.onChange(new Licensee.Status(operationMode, false));
|
||||
}
|
||||
|
||||
public void enable(Licensee licensee) {
|
||||
licensee.onChange(new Licensee.Status(operationMode, randomEnabledOrGracePeriodState()));
|
||||
licensee.onChange(new Licensee.Status(operationMode, true));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class LicenseClusterChangeTests extends AbstractLicenseServiceTestCase {
|
|||
ClusterState newState = ClusterState.builder(new ClusterName("a")).metaData(metaData).build();
|
||||
licenseService.clusterChanged(new ClusterChangedEvent("simulated", newState, oldState));
|
||||
assertThat(licensee.statuses.size(), equalTo(1));
|
||||
assertTrue(licensee.statuses.get(0).getLicenseState() == LicenseState.ENABLED);
|
||||
assertTrue(licensee.statuses.get(0).isActive());
|
||||
}
|
||||
|
||||
public void testNoNotificationOnExistingLicense() throws Exception {
|
||||
|
|
|
@ -43,7 +43,6 @@ public class LicenseRegistrationTests extends AbstractLicenseServiceTestCase {
|
|||
setInitialState(TestUtils.generateSignedLicense(TimeValue.timeValueHours(2)), licensee);
|
||||
licenseService.start();
|
||||
assertThat(licensee.statuses.size(), equalTo(1));
|
||||
final LicenseState licenseState = licensee.statuses.get(0).getLicenseState();
|
||||
assertTrue(licenseState == LicenseState.ENABLED);
|
||||
assertTrue(licensee.statuses.get(0).isActive());
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ import org.elasticsearch.common.unit.TimeValue;
|
|||
import org.elasticsearch.license.core.License;
|
||||
import org.elasticsearch.license.plugin.TestUtils;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.scheduler.SchedulerEngine;
|
||||
import org.junit.Before;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
@ -16,12 +17,12 @@ import static org.hamcrest.Matchers.equalTo;
|
|||
public class LicenseScheduleTests extends ESTestCase {
|
||||
|
||||
private License license;
|
||||
private LicenseSchedule schedule;
|
||||
private SchedulerEngine.Schedule schedule;
|
||||
|
||||
@Before
|
||||
public void setuo() throws Exception {
|
||||
license = TestUtils.generateSignedLicense(TimeValue.timeValueHours(12));
|
||||
schedule = new LicenseSchedule(license);
|
||||
schedule = LicenseService.nextLicenseCheck(license);
|
||||
}
|
||||
|
||||
public void testEnabledLicenseSchedule() throws Exception {
|
||||
|
@ -32,13 +33,13 @@ public class LicenseScheduleTests extends ESTestCase {
|
|||
|
||||
public void testGraceLicenseSchedule() throws Exception {
|
||||
long triggeredTime = license.expiryDate() + between(1,
|
||||
((int) LicenseState.GRACE_PERIOD_DURATION.getMillis()));
|
||||
((int) LicenseService.GRACE_PERIOD_DURATION.getMillis()));
|
||||
assertThat(schedule.nextScheduledTimeAfter(license.issueDate(), triggeredTime),
|
||||
equalTo(license.expiryDate() + LicenseState.GRACE_PERIOD_DURATION.getMillis()));
|
||||
equalTo(license.expiryDate() + LicenseService.GRACE_PERIOD_DURATION.getMillis()));
|
||||
}
|
||||
|
||||
public void testExpiredLicenseSchedule() throws Exception {
|
||||
long triggeredTime = license.expiryDate() + LicenseState.GRACE_PERIOD_DURATION.getMillis() +
|
||||
long triggeredTime = license.expiryDate() + LicenseService.GRACE_PERIOD_DURATION.getMillis() +
|
||||
randomIntBetween(1, 1000);
|
||||
assertThat(schedule.nextScheduledTimeAfter(license.issueDate(), triggeredTime),
|
||||
equalTo(-1L));
|
||||
|
|
|
@ -28,19 +28,19 @@ public class LicensesNotificationTests extends AbstractLicenseServiceTestCase {
|
|||
setInitialState(license, assertingLicensees);
|
||||
licenseService.start();
|
||||
for (int i = 0; i < assertingLicensees.length; i++) {
|
||||
assertLicenseStates(assertingLicensees[i], LicenseState.ENABLED);
|
||||
assertLicenseStates(assertingLicensees[i], true);
|
||||
}
|
||||
clock.fastForward(TimeValue.timeValueMillis(license.expiryDate() - clock.millis()));
|
||||
final LicensesMetaData licensesMetaData = new LicensesMetaData(license);
|
||||
licenseService.onUpdate(licensesMetaData);
|
||||
for (AssertingLicensee assertingLicensee : assertingLicensees) {
|
||||
assertLicenseStates(assertingLicensee, LicenseState.ENABLED, LicenseState.GRACE_PERIOD);
|
||||
assertLicenseStates(assertingLicensee, true);
|
||||
}
|
||||
clock.fastForward(TimeValue.timeValueMillis((license.expiryDate() +
|
||||
LicenseState.GRACE_PERIOD_DURATION.getMillis()) - clock.millis()));
|
||||
LicenseService.GRACE_PERIOD_DURATION.getMillis()) - clock.millis()));
|
||||
licenseService.onUpdate(licensesMetaData);
|
||||
for (AssertingLicensee assertingLicensee : assertingLicensees) {
|
||||
assertLicenseStates(assertingLicensee, LicenseState.ENABLED, LicenseState.GRACE_PERIOD, LicenseState.DISABLED);
|
||||
assertLicenseStates(assertingLicensee, true, false);
|
||||
}
|
||||
clock.setTime(new DateTime(DateTimeZone.UTC));
|
||||
final License newLicense = TestUtils.generateSignedLicense(TimeValue.timeValueHours(2));
|
||||
|
@ -48,12 +48,11 @@ public class LicensesNotificationTests extends AbstractLicenseServiceTestCase {
|
|||
LicensesMetaData licensesMetaData1 = new LicensesMetaData(newLicense);
|
||||
licenseService.onUpdate(licensesMetaData1);
|
||||
for (AssertingLicensee assertingLicensee : assertingLicensees) {
|
||||
assertLicenseStates(assertingLicensee, LicenseState.ENABLED, LicenseState.GRACE_PERIOD, LicenseState.DISABLED,
|
||||
LicenseState.ENABLED);
|
||||
assertLicenseStates(assertingLicensee, true, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void assertLicenseStates(AssertingLicensee licensee, LicenseState... states) {
|
||||
private void assertLicenseStates(AssertingLicensee licensee, boolean... states) {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append("Actual: ");
|
||||
msg.append(dumpLicensingStates(licensee.statuses));
|
||||
|
@ -61,7 +60,7 @@ public class LicensesNotificationTests extends AbstractLicenseServiceTestCase {
|
|||
msg.append(dumpLicensingStates(states));
|
||||
assertThat(msg.toString(), licensee.statuses.size(), equalTo(states.length));
|
||||
for (int i = 0; i < states.length; i++) {
|
||||
assertThat(msg.toString(), licensee.statuses.get(i).getLicenseState(), equalTo(states[i]));
|
||||
assertThat(msg.toString(), licensee.statuses.get(i).isActive(), equalTo(states[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,18 +69,18 @@ public class LicensesNotificationTests extends AbstractLicenseServiceTestCase {
|
|||
}
|
||||
|
||||
private String dumpLicensingStates(Licensee.Status... statuses) {
|
||||
LicenseState[] states = new LicenseState[statuses.length];
|
||||
boolean[] states = new boolean[statuses.length];
|
||||
for (int i = 0; i < statuses.length; i++) {
|
||||
states[i] = statuses[i].getLicenseState();
|
||||
states[i] = statuses[i].isActive();
|
||||
}
|
||||
return dumpLicensingStates(states);
|
||||
}
|
||||
|
||||
private String dumpLicensingStates(LicenseState... states) {
|
||||
private String dumpLicensingStates(boolean... states) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("[");
|
||||
for (int i = 0; i < states.length; i++) {
|
||||
sb.append(states[i].name());
|
||||
sb.append(states[i]);
|
||||
if (i != states.length - 1) {
|
||||
sb.append(", ");
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import org.elasticsearch.common.logging.LoggerMessageFormat;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.core.License.OperationMode;
|
||||
import org.elasticsearch.license.plugin.core.AbstractLicenseeComponent;
|
||||
import org.elasticsearch.license.plugin.core.LicenseState;
|
||||
|
||||
/**
|
||||
* {@code MonitoringLicensee} determines whether certain features of Monitoring are enabled or disabled.
|
||||
|
@ -73,7 +72,7 @@ public class MonitoringLicensee extends AbstractLicenseeComponent {
|
|||
* @return true
|
||||
*/
|
||||
public boolean isAvailable() {
|
||||
return status.getLicenseState() != LicenseState.DISABLED;
|
||||
return status.isActive();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,7 +86,7 @@ public class MonitoringLicensee extends AbstractLicenseeComponent {
|
|||
* @return {@code true} as long as the license is valid. Otherwise {@code false}.
|
||||
*/
|
||||
public boolean collectionEnabled() {
|
||||
return status.getLicenseState() != LicenseState.DISABLED;
|
||||
return status.isActive();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,7 +97,7 @@ public class MonitoringLicensee extends AbstractLicenseeComponent {
|
|||
* @return {@code true} as long as the license is valid. Otherwise {@code false}.
|
||||
*/
|
||||
public boolean cleaningEnabled() {
|
||||
return status.getLicenseState() != LicenseState.DISABLED;
|
||||
return status.isActive();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,7 +26,6 @@ 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.plugins.Plugin;
|
||||
import org.elasticsearch.rest.RestHandler;
|
||||
|
@ -110,7 +109,7 @@ public abstract class AbstractCollectorTestCase extends MonitoringIntegTestCase
|
|||
|
||||
final License license = createTestingLicense(issueDate, expiryDate);
|
||||
for (LicenseServiceForCollectors service : internalCluster().getInstances(LicenseServiceForCollectors.class)) {
|
||||
service.onChange(license.operationMode(), LicenseState.ENABLED);
|
||||
service.onChange(license.operationMode(), true);
|
||||
}
|
||||
for (LicenseServiceForCollectors service : internalCluster().getInstances(LicenseServiceForCollectors.class)) {
|
||||
service.update(license);
|
||||
|
@ -123,7 +122,7 @@ public abstract class AbstractCollectorTestCase extends MonitoringIntegTestCase
|
|||
|
||||
final License license = createTestingLicense(issueDate, expiryDate);
|
||||
for (LicenseServiceForCollectors service : internalCluster().getInstances(LicenseServiceForCollectors.class)) {
|
||||
service.onChange(license.operationMode(), LicenseState.GRACE_PERIOD);
|
||||
service.onChange(license.operationMode(), true);
|
||||
}
|
||||
for (LicenseServiceForCollectors service : internalCluster().getInstances(LicenseServiceForCollectors.class)) {
|
||||
service.update(license);
|
||||
|
@ -136,7 +135,7 @@ public abstract class AbstractCollectorTestCase extends MonitoringIntegTestCase
|
|||
|
||||
final License license = createTestingLicense(issueDate, expiryDate);
|
||||
for (LicenseServiceForCollectors service : internalCluster().getInstances(LicenseServiceForCollectors.class)) {
|
||||
service.onChange(license.operationMode(), LicenseState.DISABLED);
|
||||
service.onChange(license.operationMode(), false);
|
||||
}
|
||||
for (LicenseServiceForCollectors service : internalCluster().getInstances(LicenseServiceForCollectors.class)) {
|
||||
service.update(license);
|
||||
|
@ -149,7 +148,7 @@ public abstract class AbstractCollectorTestCase extends MonitoringIntegTestCase
|
|||
|
||||
final License license = createTestingLicense(issueDate, expiryDate);
|
||||
for (LicenseServiceForCollectors service : internalCluster().getInstances(LicenseServiceForCollectors.class)) {
|
||||
service.onChange(license.operationMode(), LicenseState.DISABLED);
|
||||
service.onChange(license.operationMode(), false);
|
||||
}
|
||||
for (LicenseServiceForCollectors service : internalCluster().getInstances(LicenseServiceForCollectors.class)) {
|
||||
service.update(license);
|
||||
|
@ -238,14 +237,14 @@ public abstract class AbstractCollectorTestCase extends MonitoringIntegTestCase
|
|||
this.licensees = licensees;
|
||||
}
|
||||
|
||||
public void onChange(License.OperationMode operationMode, LicenseState state) {
|
||||
public void onChange(License.OperationMode operationMode, boolean active) {
|
||||
for (Licensee licensee : licensees) {
|
||||
licensee.onChange(new Licensee.Status(operationMode, state));
|
||||
licensee.onChange(new Licensee.Status(operationMode, active));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Licensee.Status licenseeStatus() {
|
||||
public Licensee.Status licenseeStatus(License license) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ 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.plugins.Plugin;
|
||||
import org.elasticsearch.rest.RestHandler;
|
||||
|
@ -39,7 +38,6 @@ import static java.util.Collections.emptyList;
|
|||
import static org.elasticsearch.test.ESIntegTestCase.Scope.SUITE;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.isOneOf;
|
||||
|
||||
@ClusterScope(scope = SUITE, transportClientRatio = 0, numClientNodes = 0)
|
||||
public class LicenseIntegrationTests extends MonitoringIntegTestCase {
|
||||
|
@ -56,15 +54,15 @@ public class LicenseIntegrationTests extends MonitoringIntegTestCase {
|
|||
}
|
||||
|
||||
public void testEnableDisableLicense() {
|
||||
assertThat(getLicensee().getStatus().getLicenseState(), isOneOf(LicenseState.ENABLED, LicenseState.GRACE_PERIOD));
|
||||
assertTrue(getLicensee().getStatus().isActive());
|
||||
assertThat(getLicensee().collectionEnabled(), is(true));
|
||||
disableLicensing();
|
||||
|
||||
assertThat(getLicensee().getStatus().getLicenseState(), equalTo(LicenseState.DISABLED));
|
||||
assertThat(getLicensee().getStatus().isActive(), equalTo(false));
|
||||
assertThat(getLicensee().collectionEnabled(), is(false));
|
||||
enableLicensing();
|
||||
|
||||
assertThat(getLicensee().getStatus().getLicenseState(), isOneOf(LicenseState.ENABLED, LicenseState.GRACE_PERIOD));
|
||||
assertTrue(getLicensee().getStatus().isActive());
|
||||
assertThat(getLicensee().collectionEnabled(), is(true));
|
||||
}
|
||||
|
||||
|
@ -134,19 +132,18 @@ public class LicenseIntegrationTests extends MonitoringIntegTestCase {
|
|||
|
||||
public void enable() {
|
||||
for (Licensee licensee : licensees) {
|
||||
licensee.onChange(new Licensee.Status(License.OperationMode.BASIC,
|
||||
randomBoolean() ? LicenseState.ENABLED : LicenseState.GRACE_PERIOD));
|
||||
licensee.onChange(new Licensee.Status(License.OperationMode.BASIC, true));
|
||||
}
|
||||
}
|
||||
|
||||
public void disable() {
|
||||
for (Licensee licensee : licensees) {
|
||||
licensee.onChange(new Licensee.Status(License.OperationMode.BASIC, LicenseState.DISABLED));
|
||||
licensee.onChange(new Licensee.Status(License.OperationMode.BASIC, false));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Licensee.Status licenseeStatus() {
|
||||
public Licensee.Status licenseeStatus(License license) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.elasticsearch.xpack.monitoring.license;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.core.License.OperationMode;
|
||||
import org.elasticsearch.license.plugin.core.AbstractLicenseeTestCase;
|
||||
import org.elasticsearch.license.plugin.core.LicenseState;
|
||||
import org.elasticsearch.license.plugin.core.Licensee.Status;
|
||||
import org.elasticsearch.xpack.monitoring.MonitoringLicensee;
|
||||
|
||||
|
@ -46,19 +45,19 @@ public class MonitoringLicenseeTests extends AbstractLicenseeTestCase {
|
|||
}
|
||||
|
||||
public void testCollectionEnabledIsTrueForActiveState() {
|
||||
assertEnabled(randomEnabledOrGracePeriodState(), MonitoringLicensee::collectionEnabled, true);
|
||||
assertEnabled(true, MonitoringLicensee::collectionEnabled, true);
|
||||
}
|
||||
|
||||
public void testCollectionEnabledIsFalseForInactiveState() {
|
||||
assertEnabled(LicenseState.DISABLED, MonitoringLicensee::collectionEnabled, false);
|
||||
assertEnabled(false, MonitoringLicensee::collectionEnabled, false);
|
||||
}
|
||||
|
||||
public void testCleaningEnabledIsTrueForActiveState() {
|
||||
assertEnabled(randomEnabledOrGracePeriodState(), MonitoringLicensee::cleaningEnabled, true);
|
||||
assertEnabled(true, MonitoringLicensee::cleaningEnabled, true);
|
||||
}
|
||||
|
||||
public void testCleaningEnabledIsFalseForInactiveState() {
|
||||
assertEnabled(LicenseState.DISABLED, MonitoringLicensee::cleaningEnabled, false);
|
||||
assertEnabled(false, MonitoringLicensee::cleaningEnabled, false);
|
||||
}
|
||||
|
||||
public void testAllowUpdateRetentionIsTrueForNotBasic() {
|
||||
|
@ -77,19 +76,19 @@ public class MonitoringLicenseeTests extends AbstractLicenseeTestCase {
|
|||
/**
|
||||
* Assert that the {@link #licensee} is {@code predicate}d as {@code expected} when setting the {@code state}.
|
||||
*
|
||||
* @param state The state that should cause the {@code expected} {@code predicate}.
|
||||
* @param active The state that should cause the {@code expected} {@code predicate}.
|
||||
* @param predicate The method to invoke (expected to be an instance method).
|
||||
* @param expected The expected outcome given the {@code state} and {@code predicate}.
|
||||
*/
|
||||
private void assertEnabled(LicenseState state, Predicate<MonitoringLicensee> predicate, boolean expected) {
|
||||
private void assertEnabled(boolean active, Predicate<MonitoringLicensee> predicate, boolean expected) {
|
||||
Status status = mock(Status.class);
|
||||
when(status.getLicenseState()).thenReturn(state);
|
||||
when(status.isActive()).thenReturn(active);
|
||||
|
||||
licensee.onChange(status);
|
||||
|
||||
assertThat(predicate.test(licensee), equalTo(expected));
|
||||
|
||||
verify(status).getLicenseState();
|
||||
verify(status).isActive();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
package org.elasticsearch.xpack.security;
|
||||
|
||||
import org.elasticsearch.license.core.License.OperationMode;
|
||||
import org.elasticsearch.license.plugin.core.LicenseState;
|
||||
import org.elasticsearch.license.plugin.core.Licensee.Status;
|
||||
|
||||
|
||||
|
@ -53,7 +52,7 @@ public class SecurityLicenseState {
|
|||
* @return true if the license allows for the stats and health APIs to be used.
|
||||
*/
|
||||
public boolean statsAndHealthEnabled() {
|
||||
return status.getLicenseState() != LicenseState.DISABLED;
|
||||
return status.isActive();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,7 +35,6 @@ 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.plugins.Plugin;
|
||||
import org.elasticsearch.rest.RestHandler;
|
||||
|
@ -309,13 +308,13 @@ public class LicensingTests extends SecurityIntegTestCase {
|
|||
|
||||
void enable(OperationMode operationMode) {
|
||||
for (Licensee licensee : licensees) {
|
||||
licensee.onChange(new Licensee.Status(operationMode, LicenseState.ENABLED));
|
||||
licensee.onChange(new Licensee.Status(operationMode, true));
|
||||
}
|
||||
}
|
||||
|
||||
void disable(OperationMode operationMode) {
|
||||
for (Licensee licensee : licensees) {
|
||||
licensee.onChange(new Licensee.Status(operationMode, LicenseState.DISABLED));
|
||||
licensee.onChange(new Licensee.Status(operationMode, false));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ package org.elasticsearch.xpack.security;
|
|||
|
||||
import org.elasticsearch.license.core.License;
|
||||
import org.elasticsearch.license.core.License.OperationMode;
|
||||
import org.elasticsearch.license.plugin.core.LicenseState;
|
||||
import org.elasticsearch.license.plugin.core.Licensee;
|
||||
import org.elasticsearch.xpack.security.SecurityLicenseState.EnabledRealmType;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
@ -31,8 +30,7 @@ public class SecurityLicenseStateTests extends ESTestCase {
|
|||
|
||||
public void testBasic() {
|
||||
SecurityLicenseState licenseState = new SecurityLicenseState();
|
||||
licenseState.updateStatus(new Licensee.Status(License.OperationMode.BASIC,
|
||||
randomBoolean() ? LicenseState.ENABLED : LicenseState.GRACE_PERIOD));
|
||||
licenseState.updateStatus(new Licensee.Status(License.OperationMode.BASIC, true));
|
||||
|
||||
assertThat(licenseState.authenticationAndAuthorizationEnabled(), is(false));
|
||||
assertThat(licenseState.ipFilteringEnabled(), is(false));
|
||||
|
@ -44,7 +42,7 @@ public class SecurityLicenseStateTests extends ESTestCase {
|
|||
|
||||
public void testBasicExpired() {
|
||||
SecurityLicenseState licenseState = new SecurityLicenseState();
|
||||
licenseState.updateStatus(new Licensee.Status(License.OperationMode.BASIC, LicenseState.DISABLED));
|
||||
licenseState.updateStatus(new Licensee.Status(License.OperationMode.BASIC, false));
|
||||
|
||||
assertThat(licenseState.authenticationAndAuthorizationEnabled(), is(false));
|
||||
assertThat(licenseState.ipFilteringEnabled(), is(false));
|
||||
|
@ -56,8 +54,7 @@ public class SecurityLicenseStateTests extends ESTestCase {
|
|||
|
||||
public void testStandard() {
|
||||
SecurityLicenseState licenseState = new SecurityLicenseState();
|
||||
licenseState.updateStatus(new Licensee.Status(OperationMode.STANDARD,
|
||||
randomBoolean() ? LicenseState.ENABLED : LicenseState.GRACE_PERIOD));
|
||||
licenseState.updateStatus(new Licensee.Status(OperationMode.STANDARD, true));
|
||||
|
||||
assertThat(licenseState.authenticationAndAuthorizationEnabled(), is(true));
|
||||
assertThat(licenseState.ipFilteringEnabled(), is(false));
|
||||
|
@ -69,7 +66,7 @@ public class SecurityLicenseStateTests extends ESTestCase {
|
|||
|
||||
public void testStandardExpired() {
|
||||
SecurityLicenseState licenseState = new SecurityLicenseState();
|
||||
licenseState.updateStatus(new Licensee.Status(OperationMode.STANDARD, LicenseState.DISABLED));
|
||||
licenseState.updateStatus(new Licensee.Status(OperationMode.STANDARD, false));
|
||||
|
||||
assertThat(licenseState.authenticationAndAuthorizationEnabled(), is(true));
|
||||
assertThat(licenseState.ipFilteringEnabled(), is(false));
|
||||
|
@ -81,8 +78,7 @@ public class SecurityLicenseStateTests extends ESTestCase {
|
|||
|
||||
public void testGold() {
|
||||
SecurityLicenseState licenseState = new SecurityLicenseState();
|
||||
licenseState.updateStatus(new Licensee.Status(License.OperationMode.GOLD,
|
||||
randomBoolean() ? LicenseState.ENABLED : LicenseState.GRACE_PERIOD));
|
||||
licenseState.updateStatus(new Licensee.Status(License.OperationMode.GOLD, true));
|
||||
|
||||
assertThat(licenseState.authenticationAndAuthorizationEnabled(), is(true));
|
||||
assertThat(licenseState.ipFilteringEnabled(), is(true));
|
||||
|
@ -94,7 +90,7 @@ public class SecurityLicenseStateTests extends ESTestCase {
|
|||
|
||||
public void testGoldExpired() {
|
||||
SecurityLicenseState licenseState = new SecurityLicenseState();
|
||||
licenseState.updateStatus(new Licensee.Status(License.OperationMode.GOLD, LicenseState.DISABLED));
|
||||
licenseState.updateStatus(new Licensee.Status(License.OperationMode.GOLD, false));
|
||||
|
||||
assertThat(licenseState.authenticationAndAuthorizationEnabled(), is(true));
|
||||
assertThat(licenseState.ipFilteringEnabled(), is(true));
|
||||
|
@ -106,8 +102,7 @@ public class SecurityLicenseStateTests extends ESTestCase {
|
|||
|
||||
public void testPlatinum() {
|
||||
SecurityLicenseState licenseState = new SecurityLicenseState();
|
||||
licenseState.updateStatus(new Licensee.Status(License.OperationMode.PLATINUM,
|
||||
randomBoolean() ? LicenseState.ENABLED : LicenseState.GRACE_PERIOD));
|
||||
licenseState.updateStatus(new Licensee.Status(License.OperationMode.PLATINUM, true));
|
||||
|
||||
assertThat(licenseState.authenticationAndAuthorizationEnabled(), is(true));
|
||||
assertThat(licenseState.ipFilteringEnabled(), is(true));
|
||||
|
@ -119,7 +114,7 @@ public class SecurityLicenseStateTests extends ESTestCase {
|
|||
|
||||
public void testPlatinumExpired() {
|
||||
SecurityLicenseState licenseState = new SecurityLicenseState();
|
||||
licenseState.updateStatus(new Licensee.Status(License.OperationMode.PLATINUM, LicenseState.DISABLED));
|
||||
licenseState.updateStatus(new Licensee.Status(License.OperationMode.PLATINUM, false));
|
||||
|
||||
assertThat(licenseState.authenticationAndAuthorizationEnabled(), is(true));
|
||||
assertThat(licenseState.ipFilteringEnabled(), is(true));
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.elasticsearch.common.Strings;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.core.License.OperationMode;
|
||||
import org.elasticsearch.license.plugin.core.AbstractLicenseeComponent;
|
||||
import org.elasticsearch.license.plugin.core.LicenseState;
|
||||
|
||||
public class WatcherLicensee extends AbstractLicenseeComponent {
|
||||
|
||||
|
@ -60,7 +59,7 @@ public class WatcherLicensee extends AbstractLicenseeComponent {
|
|||
// status is volatile, so a local variable is used for a consistent view
|
||||
Status localStatus = status;
|
||||
|
||||
if (localStatus.getLicenseState() == LicenseState.DISABLED) {
|
||||
if (localStatus.isActive() == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@ package org.elasticsearch.xpack.watcher.license;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.core.License;
|
||||
import org.elasticsearch.license.plugin.core.AbstractLicenseeTestCase;
|
||||
import org.elasticsearch.license.plugin.core.LicenseState;
|
||||
import org.elasticsearch.license.plugin.core.Licensee;
|
||||
import org.elasticsearch.xpack.watcher.WatcherLicensee;
|
||||
|
||||
import static org.elasticsearch.license.core.License.OperationMode.BASIC;
|
||||
|
|
Loading…
Reference in New Issue