Skip to content

Commit

Permalink
Do not add index event listener if CCR disabled (#37432)
Browse files Browse the repository at this point in the history
Currently we add the CcrRestoreSourceService as a index event
listener. However, if ccr is disabled, this service is null and we
attempt to add a null listener throwing an exception. This commit only
adds the listener if ccr is enabled.
  • Loading branch information
Tim-Brooks authored Jan 18, 2019
1 parent cd41289 commit fe753ee
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ public Map<String, Repository.Factory> getInternalRepositories(Environment env,

@Override
public void onIndexModule(IndexModule indexModule) {
indexModule.addIndexEventListener(this.restoreSourceService.get());
if (enabled) {
indexModule.addIndexEventListener(this.restoreSourceService.get());
}
}

protected XPackLicenseState getLicenseState() { return XPackPlugin.getSharedLicenseState(); }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

package org.elasticsearch.xpack.ccr;

import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.xpack.core.XPackClientPlugin;
import org.elasticsearch.xpack.core.XPackSettings;

import java.util.Collection;
import java.util.Collections;

public class CcrDisabledIT extends ESIntegTestCase {

public void testClusterCanStartWithCcrInstalledButNotEnabled() throws Exception {
// TODO: Assert that x-pack ccr feature is not enabled once feature functionality has been added
ensureGreen();
}

@Override
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder().put(super.nodeSettings(nodeOrdinal)).put(XPackSettings.CCR_ENABLED_SETTING.getKey(), true)
.put(XPackSettings.SECURITY_ENABLED.getKey(), false).build();
}

@Override
protected Settings transportClientSettings() {
return Settings.builder().put(super.transportClientSettings()).put(XPackSettings.SECURITY_ENABLED.getKey(), false).build();
}

@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singletonList(LocalStateCcr.class);
}

@Override
protected Collection<Class<? extends Plugin>> transportClientPlugins() {
return Collections.singletonList(XPackClientPlugin.class);
}
}

0 comments on commit fe753ee

Please sign in to comment.