ensure no operation is blocked before initial license notification

closes elastic/elasticsearch#906

update comment

Original commit: elastic/x-pack-elasticsearch@0bd788720f
This commit is contained in:
Areek Zillur 2015-11-09 11:04:42 -05:00
parent 28326a2c4c
commit dcae5fb5f0
2 changed files with 14 additions and 15 deletions

View File

@ -16,8 +16,9 @@ import org.elasticsearch.license.plugin.core.Licensee.Status;
*/
public class ShieldLicenseState {
// if we start disabled then we can emit false disabled messages and block legitimate requests...
protected volatile Status status = new Status(OperationMode.TRIAL, LicenseState.ENABLED);
// we initialize the licensee status to enabled with trial operation mode to ensure no
// legitimate requests are blocked before initial license plugin notification
protected volatile Status status = Status.ENABLED;
/**
* @return true if the license allows for security features to be enabled (authc, authz, ip filter, audit, etc)

View File

@ -10,7 +10,6 @@ import org.elasticsearch.common.Strings;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.license.core.License;
import org.elasticsearch.license.core.License.OperationMode;
import org.elasticsearch.license.plugin.core.*;
import org.elasticsearch.shield.ShieldPlugin;
@ -25,16 +24,16 @@ public class ShieldLicensee extends AbstractLicenseeComponent<ShieldLicensee> im
@Inject
public ShieldLicensee(Settings settings, LicenseeRegistry clientService, ShieldLicenseState shieldLicenseState) {
super(settings, ShieldPlugin.NAME, clientService);
add(new Listener() {
@Override
public void onChange(Status status) {
shieldLicenseState.updateStatus(status);
}
});
this.shieldLicenseState = shieldLicenseState;
this.isTribeNode = settings.getGroups("tribe", true).isEmpty() == false;
}
@Override
public void onChange(Status status) {
super.onChange(status);
shieldLicenseState.updateStatus(status);
}
@Override
public String[] expirationMessages() {
return new String[] {
@ -74,12 +73,11 @@ public class ShieldLicensee extends AbstractLicenseeComponent<ShieldLicensee> im
}
@Override
protected void doStart() throws ElasticsearchException {;
if (isTribeNode) {
//TODO currently we disable licensing on tribe node. remove this once es core supports merging cluster
this.status = new Status(OperationMode.TRIAL, LicenseState.ENABLED);
shieldLicenseState.updateStatus(status);
} else {
protected void doStart() throws ElasticsearchException {
// we rely on the initial licensee state to be enabled with trial operation mode
// to ensure no operation is blocked due to not registering the licensee on a
// tribe node
if (!isTribeNode) {
super.doStart();
}
}