From ef7d4e2579dd54801b264e0b946855640d95619a Mon Sep 17 00:00:00 2001 From: Areek Zillur Date: Fri, 21 Aug 2015 14:04:30 -0400 Subject: [PATCH] stub out acknowledge callbacks for commercial plugins Original commit: elastic/x-pack-elasticsearch@d16f9dc1dfb36f711fc37a4b4c059871b796ebdd --- .../marvel/license/LicenseService.java | 17 ++++++++++++----- .../shield/license/LicenseService.java | 14 +++++++++++++- .../watcher/license/LicenseService.java | 16 ++++++++++++---- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/marvel/src/main/java/org/elasticsearch/marvel/license/LicenseService.java b/marvel/src/main/java/org/elasticsearch/marvel/license/LicenseService.java index bd6a7a36439..aadf20c7fc3 100644 --- a/marvel/src/main/java/org/elasticsearch/marvel/license/LicenseService.java +++ b/marvel/src/main/java/org/elasticsearch/marvel/license/LicenseService.java @@ -19,10 +19,7 @@ import org.elasticsearch.license.plugin.core.LicensesService; import org.elasticsearch.marvel.MarvelPlugin; import org.elasticsearch.marvel.mode.Mode; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Locale; +import java.util.*; public class LicenseService extends AbstractLifecycleComponent { @@ -36,6 +33,7 @@ public class LicenseService extends AbstractLifecycleComponent { private final LicensesManagerService managerService; private final LicensesClientService clientService; private final Collection expirationLoggers; + private final LicensesClientService.AcknowledgementCallback acknowledgementCallback; private volatile Mode mode; @@ -77,11 +75,20 @@ public class LicenseService extends AbstractLifecycleComponent { } } ); + this.acknowledgementCallback = new LicensesClientService.AcknowledgementCallback() { + @Override + public List acknowledge(License currentLicense, License newLicense) { + // TODO: add messages to be acknowledged when installing newLicense from currentLicense + // NOTE: currentLicense can be null, as a license registration can happen before + // a trial license could be generated + return Collections.emptyList(); + } + }; } @Override protected void doStart() throws ElasticsearchException { - clientService.register(FEATURE_NAME, TRIAL_LICENSE_OPTIONS, expirationLoggers, null, new InternalListener(this)); + clientService.register(FEATURE_NAME, TRIAL_LICENSE_OPTIONS, expirationLoggers, acknowledgementCallback, new InternalListener(this)); } @Override diff --git a/shield/src/main/java/org/elasticsearch/shield/license/LicenseService.java b/shield/src/main/java/org/elasticsearch/shield/license/LicenseService.java index 778c7f1e498..d32f0ef41ee 100644 --- a/shield/src/main/java/org/elasticsearch/shield/license/LicenseService.java +++ b/shield/src/main/java/org/elasticsearch/shield/license/LicenseService.java @@ -18,6 +18,8 @@ import org.elasticsearch.license.plugin.core.LicensesClientService; import org.elasticsearch.shield.ShieldPlugin; import java.util.Collection; +import java.util.Collections; +import java.util.List; import java.util.Locale; /** @@ -35,6 +37,7 @@ public class LicenseService extends AbstractLifecycleComponent { private final LicensesClientService licensesClientService; private final LicenseEventsNotifier notifier; private final Collection expirationLoggers; + private final LicensesClientService.AcknowledgementCallback acknowledgementCallback; private boolean enabled = false; @@ -78,6 +81,15 @@ public class LicenseService extends AbstractLifecycleComponent { } } ); + this.acknowledgementCallback = new LicensesClientService.AcknowledgementCallback() { + @Override + public List acknowledge(License currentLicense, License newLicense) { + // TODO: add messages to be acknowledged when installing newLicense from currentLicense + // NOTE: currentLicense can be null, as a license registration can happen before + // a trial license could be generated + return Collections.emptyList(); + } + }; } public synchronized boolean enabled() { @@ -87,7 +99,7 @@ public class LicenseService extends AbstractLifecycleComponent { @Override protected void doStart() throws ElasticsearchException { if (settings.getGroups("tribe", true).isEmpty()) { - licensesClientService.register(FEATURE_NAME, TRIAL_LICENSE_OPTIONS, expirationLoggers, null, new InternalListener()); + licensesClientService.register(FEATURE_NAME, TRIAL_LICENSE_OPTIONS, expirationLoggers, acknowledgementCallback, new InternalListener()); } else { //TODO currently we disable licensing on tribe node. remove this once es core supports merging cluster new InternalListener().onEnabled(null); diff --git a/watcher/src/main/java/org/elasticsearch/watcher/license/LicenseService.java b/watcher/src/main/java/org/elasticsearch/watcher/license/LicenseService.java index 768398a2698..41463a8e865 100644 --- a/watcher/src/main/java/org/elasticsearch/watcher/license/LicenseService.java +++ b/watcher/src/main/java/org/elasticsearch/watcher/license/LicenseService.java @@ -17,9 +17,7 @@ import org.elasticsearch.license.plugin.core.LicensesClientService; import org.elasticsearch.license.plugin.core.LicensesService; import org.elasticsearch.watcher.WatcherPlugin; -import java.util.Arrays; -import java.util.Collection; -import java.util.Locale; +import java.util.*; /** * @@ -35,6 +33,7 @@ public class LicenseService extends AbstractLifecycleComponent { private final LicensesClientService clientService; private final Collection expirationLoggers; + private final LicensesClientService.AcknowledgementCallback acknowledgementCallback; private volatile boolean enabled; @@ -80,11 +79,20 @@ public class LicenseService extends AbstractLifecycleComponent { } } ); + this.acknowledgementCallback = new LicensesClientService.AcknowledgementCallback() { + @Override + public List acknowledge(License currentLicense, License newLicense) { + // TODO: add messages to be acknowledged when installing newLicense from currentLicense + // NOTE: currentLicense can be null, as a license registration can happen before + // a trial license could be generated + return Collections.emptyList(); + } + }; } @Override protected void doStart() throws ElasticsearchException { - clientService.register(FEATURE_NAME, TRIAL_LICENSE_OPTIONS, expirationLoggers, null, new InternalListener(this)); + clientService.register(FEATURE_NAME, TRIAL_LICENSE_OPTIONS, expirationLoggers, acknowledgementCallback, new InternalListener(this)); } @Override