LicensesService:
- remove scheduled notification offset - improve test to test serial notification Original commit: elastic/x-pack-elasticsearch@fbf811efaa
This commit is contained in:
parent
bf4d249221
commit
7d41146f38
|
@ -60,7 +60,6 @@ import static org.elasticsearch.license.core.ESLicenses.reduceAndMap;
|
|||
* - calls {@link #notifyFeatures(LicensesMetaData)} to notify all registered feature(s)
|
||||
* - if there is any license(s) with a future expiry date in the current cluster state:
|
||||
* - schedules a delayed {@link LicensingClientNotificationJob} on the MIN of all the expiry dates of all the registered feature(s)
|
||||
* - 100ms is added to the delay to make sure that the expiring license has actually expired
|
||||
*
|
||||
* The {@link LicensingClientNotificationJob} calls {@link #notifyFeaturesAndScheduleNotification(LicensesMetaData)} to schedule
|
||||
* another delayed {@link LicensingClientNotificationJob} as stated above. It is a no-op in case of a global block on
|
||||
|
@ -466,7 +465,6 @@ public class LicensesService extends AbstractLifecycleComponent<LicensesService>
|
|||
*/
|
||||
private long notifyFeatures(LicensesMetaData currentLicensesMetaData) {
|
||||
long nextScheduleFrequency = -1l;
|
||||
long offset = TimeValue.timeValueMillis(100).getMillis();
|
||||
StringBuilder sb = new StringBuilder("Registered listeners: [ ");
|
||||
for (ListenerHolder listenerHolder : registeredListeners) {
|
||||
|
||||
|
@ -497,9 +495,9 @@ public class LicensesService extends AbstractLifecycleComponent<LicensesService>
|
|||
|
||||
listenerHolder.enableFeatureIfNeeded();
|
||||
if (nextScheduleFrequency == -1l) {
|
||||
nextScheduleFrequency = expiryDuration + offset;
|
||||
nextScheduleFrequency = expiryDuration;
|
||||
} else {
|
||||
nextScheduleFrequency = Math.min(expiryDuration + offset, nextScheduleFrequency);
|
||||
nextScheduleFrequency = Math.min(expiryDuration, nextScheduleFrequency);
|
||||
}
|
||||
} else {
|
||||
sb.append("calling disableFeatureIfNeeded");
|
||||
|
|
|
@ -228,10 +228,11 @@ public class LicensesServiceTests extends AbstractLicensesIntegrationTests {
|
|||
LicensesManagerService masterLicensesManagerService = masterLicensesManagerService();
|
||||
Map<TestTrackingClientListener, List<Action>> clientListenersWithActions = new HashMap<>();
|
||||
|
||||
TimeValue expiryDuration = TimeValue.timeValueSeconds(0);
|
||||
for (int i = 0; i < randomIntBetween(3, 10); i++) {
|
||||
final TestTrackingClientListener clientListener = new TestTrackingClientListener();
|
||||
String feature = randomRealisticUnicodeOfCodepointLengthBetween(2, 10);
|
||||
TimeValue expiryDuration = TimeValue.timeValueSeconds(randomIntBetween(1, 5));
|
||||
expiryDuration = TimeValue.timeValueMillis(randomIntBetween(1, 5) * 1000l + expiryDuration.millis());
|
||||
List<Action> actions = new ArrayList<>();
|
||||
|
||||
if (randomBoolean()) {
|
||||
|
|
Loading…
Reference in New Issue