[Rollup] Make Rollup a Basic license feature (elastic/x-pack-elasticsearch#4246)

* Make Rollup a Basic license feature

Original commit: elastic/x-pack-elasticsearch@ef1ee98855
This commit is contained in:
Zachary Tong 2018-03-30 06:23:08 -07:00 committed by GitHub
parent 2aeff7713c
commit 54539a1eb0
2 changed files with 4 additions and 43 deletions

View File

@ -82,7 +82,6 @@ public class XPackLicenseState {
messages.put(XPackField.MACHINE_LEARNING, XPackLicenseState::machineLearningAcknowledgementMessages); messages.put(XPackField.MACHINE_LEARNING, XPackLicenseState::machineLearningAcknowledgementMessages);
messages.put(XPackField.LOGSTASH, XPackLicenseState::logstashAcknowledgementMessages); messages.put(XPackField.LOGSTASH, XPackLicenseState::logstashAcknowledgementMessages);
messages.put(XPackField.SQL, XPackLicenseState::sqlAcknowledgementMessages); messages.put(XPackField.SQL, XPackLicenseState::sqlAcknowledgementMessages);
messages.put(XPackField.ROLLUP, XPackLicenseState::rollupAcknowledgementMessages);
ACKNOWLEDGMENT_MESSAGES = Collections.unmodifiableMap(messages); ACKNOWLEDGMENT_MESSAGES = Collections.unmodifiableMap(messages);
} }
@ -233,22 +232,6 @@ public class XPackLicenseState {
return Strings.EMPTY_ARRAY; return Strings.EMPTY_ARRAY;
} }
private static String[] rollupAcknowledgementMessages(OperationMode currentMode, OperationMode newMode) {
switch (newMode) {
case BASIC:
case STANDARD:
case GOLD:
switch (currentMode) {
case TRIAL:
case PLATINUM:
return new String[] { "Creating new Rollup jobs or starting existing jobs will be disabled.",
"All existing jobs can still be queried with GET APIs, and RollupSearch continues to function." };
}
break;
}
return Strings.EMPTY_ARRAY;
}
/** A wrapper for the license mode and state, to allow atomically swapping. */ /** A wrapper for the license mode and state, to allow atomically swapping. */
private static class Status { private static class Status {
@ -499,26 +482,12 @@ public class XPackLicenseState {
} }
/** /**
* Determine if Rollup should be enabled. * Rollup is always available as long as there is a valid license
* <p>
* Rollup is only disabled when the license has expired or if the
* mode is not:
* <ul>
* <li>{@link OperationMode#PLATINUM}</li>
* <li>{@link OperationMode#TRIAL}</li>
* </ul>
* *
* @return {@code true} as long as the license is valid. Otherwise * @return true if the license is active
* {@code false}.
*/ */
public boolean isRollupAllowed() { public boolean isRollupAllowed() {
// status is volatile return status.active;
Status localStatus = status;
OperationMode operationMode = localStatus.mode;
boolean licensed = operationMode == OperationMode.TRIAL || operationMode == OperationMode.PLATINUM;
return licensed && localStatus.active;
} }
/** /**

View File

@ -32,16 +32,14 @@ import java.util.function.Consumer;
public class TransportStopRollupAction extends TransportTasksAction<RollupJobTask, StopRollupJobAction.Request, public class TransportStopRollupAction extends TransportTasksAction<RollupJobTask, StopRollupJobAction.Request,
StopRollupJobAction.Response, StopRollupJobAction.Response> { StopRollupJobAction.Response, StopRollupJobAction.Response> {
private final XPackLicenseState licenseState;
@Inject @Inject
public TransportStopRollupAction(Settings settings, TransportService transportService, ThreadPool threadPool, public TransportStopRollupAction(Settings settings, TransportService transportService, ThreadPool threadPool,
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver,
ClusterService clusterService, XPackLicenseState licenseState) { ClusterService clusterService) {
super(settings, StopRollupJobAction.NAME, threadPool, clusterService, transportService, actionFilters, super(settings, StopRollupJobAction.NAME, threadPool, clusterService, transportService, actionFilters,
indexNameExpressionResolver, StopRollupJobAction.Request::new, StopRollupJobAction.Response::new, ThreadPool.Names.SAME); indexNameExpressionResolver, StopRollupJobAction.Request::new, StopRollupJobAction.Response::new, ThreadPool.Names.SAME);
this.licenseState = licenseState;
} }
@Override @Override
@ -51,12 +49,6 @@ public class TransportStopRollupAction extends TransportTasksAction<RollupJobTas
@Override @Override
protected void doExecute(Task task, StopRollupJobAction.Request request, ActionListener<StopRollupJobAction.Response> listener) { protected void doExecute(Task task, StopRollupJobAction.Request request, ActionListener<StopRollupJobAction.Response> listener) {
if (!licenseState.isRollupAllowed()) {
listener.onFailure(LicenseUtils.newComplianceException(XPackField.ROLLUP));
return;
}
super.doExecute(task, request, listener); super.doExecute(task, request, listener);
} }