Deprecate tribe service

This commit deprecates the tribe service so that deprecation log
messages are delivered if a tribe node is configured.

Relates #24598
This commit is contained in:
Guillaume Le Floch 2017-06-15 18:41:05 +02:00 committed by Jason Tedor
parent 428e70758a
commit a9014dfcc5
3 changed files with 34 additions and 1 deletions

View File

@ -49,6 +49,8 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.network.NetworkService;
import org.elasticsearch.common.regex.Regex;
@ -230,6 +232,10 @@ public class TribeService extends AbstractLifecycleComponent {
this.blockIndicesMetadata = BLOCKS_METADATA_INDICES_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY);
this.blockIndicesRead = BLOCKS_READ_INDICES_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY);
this.blockIndicesWrite = BLOCKS_WRITE_INDICES_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY);
if (!nodes.isEmpty()) {
new DeprecationLogger(Loggers.getLogger(TribeService.class))
.deprecated("tribe nodes are deprecated in favor of cross-cluster search and will be removed in Elasticsearch 7.0.0");
}
this.onConflict = ON_CONFLICT_SETTING.get(settings);
}

View File

@ -19,6 +19,7 @@
package org.elasticsearch.tribe;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.NamedDiff;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.io.stream.StreamInput;
@ -27,11 +28,14 @@ import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.env.Environment;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.node.MockNode;
import org.elasticsearch.node.Node;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.TestCustomMetaData;
import org.elasticsearch.transport.MockTcpTransportPlugin;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -180,6 +184,28 @@ public class TribeServiceTests extends ESTestCase {
assertEquals(mergedCustom.getData(), "data2"+String.valueOf(n));
}
public void testTribeNodeDeprecation() throws IOException {
final Path tempDir = createTempDir();
Settings.Builder settings = Settings.builder()
.put("node.name", "test-node")
.put("path.home", tempDir)
.put(NetworkModule.HTTP_ENABLED.getKey(), false)
.put(NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), "mock-socket-network");
final boolean tribeServiceEnable = randomBoolean();
if (tribeServiceEnable) {
String clusterName = "single-node-cluster";
String tribeSetting = "tribe." + clusterName + ".";
settings.put(tribeSetting + ClusterName.CLUSTER_NAME_SETTING.getKey(), clusterName)
.put(tribeSetting + NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), "mock-socket-network");
}
try (Node node = new MockNode(settings.build(),Collections.singleton(MockTcpTransportPlugin.class) )) {
if (tribeServiceEnable) {
assertWarnings("tribe nodes are deprecated in favor of cross-cluster search and will be removed in Elasticsearch 7.0.0");
}
}
}
static class MergableCustomMetaData1 extends TestCustomMetaData
implements TribeService.MergableCustomMetaData<MergableCustomMetaData1> {
public static final String TYPE = "custom_md_1";

View File

@ -99,6 +99,7 @@ public class TribeUnitTests extends ESTestCase {
.put(Environment.PATH_CONF_SETTING.getKey(), pathConf)
.build();
assertTribeNodeSuccessfullyCreated(settings);
assertWarnings("tribe nodes are deprecated in favor of cross-cluster search and will be removed in Elasticsearch 7.0.0");
}
private static void assertTribeNodeSuccessfullyCreated(Settings extraSettings) throws Exception {