Skip to content

Commit bfdeb0c

Browse files
committed
Simplify the logic -- only update if it has increased
1 parent b0c7f0b commit bfdeb0c

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@
3333
*/
3434
public class XPackLicenseState {
3535

36-
/**
37-
* For features that are used at high frequency (e.g. per-search or per-document, etc.), we don't want to bother updating
38-
* the 'last used' timestamp more often than some minimum frequency.
39-
*/
40-
private static final long FEATURE_USAGE_MINIMUM_ELAPSED_TIME_MILLIS = TimeValue.timeValueSeconds(10).getMillis();
41-
4236
/** Messages for each feature which are printed when the license expires. */
4337
static final Map<String, String[]> EXPIRATION_MESSAGES;
4438
static {
@@ -453,11 +447,11 @@ public String statusDescription() {
453447

454448
void featureUsed(LicensedFeature feature) {
455449
checkExpiry();
456-
// if at least the minimum elapsed time has passed, then update the most recently used time for this feature
450+
// update the most recent usage time, but only if isn't already present or has increased
457451
final FeatureUsage feat = new FeatureUsage(feature, null);
458-
final long now = epochMillisProvider.getAsLong();
459452
final Long mostRecent = usage.get(feat);
460-
if (mostRecent == null || now - mostRecent >= FEATURE_USAGE_MINIMUM_ELAPSED_TIME_MILLIS) {
453+
final long now = epochMillisProvider.getAsLong();
454+
if (mostRecent == null || now > mostRecent) {
461455
usage.put(feat, now);
462456
}
463457
}

0 commit comments

Comments
 (0)