Filter node.roles setting in transport client (#64276)
This commit filters out the node.roles setting from the transport client, since the transport client does not take on these roles.
This commit is contained in:
parent
13fb6dbe4b
commit
827dd39a12
|
@ -19,15 +19,14 @@
|
|||
|
||||
package org.elasticsearch.client.transport;
|
||||
|
||||
import org.elasticsearch.action.ActionType;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.ActionModule;
|
||||
import org.elasticsearch.action.ActionRequest;
|
||||
import org.elasticsearch.action.ActionResponse;
|
||||
import org.elasticsearch.action.ActionType;
|
||||
import org.elasticsearch.client.support.AbstractClient;
|
||||
import org.elasticsearch.cluster.ClusterModule;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
|
||||
import org.elasticsearch.common.UUIDs;
|
||||
import org.elasticsearch.common.breaker.CircuitBreaker;
|
||||
import org.elasticsearch.common.component.LifecycleComponent;
|
||||
|
@ -69,7 +68,6 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -139,19 +137,13 @@ public abstract class TransportClient extends AbstractClient {
|
|||
providedSettings = Settings.builder().put(providedSettings).put(Node.NODE_NAME_SETTING.getKey(), "_client_").build();
|
||||
}
|
||||
final PluginsService pluginsService = newPluginService(providedSettings, plugins);
|
||||
final List<Closeable> resourcesToClose = new ArrayList<>();
|
||||
final Settings settings =
|
||||
Settings.builder()
|
||||
.put(defaultSettings)
|
||||
.put(pluginsService.updatedSettings())
|
||||
.put(TransportSettings.FEATURE_PREFIX + "." + TRANSPORT_CLIENT_FEATURE, true)
|
||||
.build();
|
||||
final Set<DiscoveryNodeRole> possibleRoles = pluginsService.filterPlugins(Plugin.class)
|
||||
.stream()
|
||||
.map(Plugin::getRoles)
|
||||
.flatMap(Set::stream)
|
||||
.collect(Collectors.toSet());
|
||||
DiscoveryNode.setAdditionalRoles(possibleRoles);
|
||||
final List<Closeable> resourcesToClose = new ArrayList<>();
|
||||
final ThreadPool threadPool = new ThreadPool(settings);
|
||||
resourcesToClose.add(() -> ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS));
|
||||
final NetworkService networkService = new NetworkService(emptyList());
|
||||
|
|
|
@ -37,8 +37,6 @@ import org.elasticsearch.action.admin.cluster.configuration.ClearVotingConfigExc
|
|||
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
|
||||
import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags;
|
||||
import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags.Flag;
|
||||
import org.elasticsearch.cluster.coordination.NoMasterBlockService;
|
||||
import org.elasticsearch.index.IndexingPressure;
|
||||
import org.elasticsearch.action.support.replication.TransportReplicationAction;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.client.transport.TransportClient;
|
||||
|
@ -46,6 +44,7 @@ import org.elasticsearch.cluster.ClusterName;
|
|||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.action.index.MappingUpdatedAction;
|
||||
import org.elasticsearch.cluster.coordination.ClusterBootstrapService;
|
||||
import org.elasticsearch.cluster.coordination.NoMasterBlockService;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetadata;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
|
||||
|
@ -88,6 +87,7 @@ import org.elasticsearch.env.ShardLockObtainFailedException;
|
|||
import org.elasticsearch.http.HttpServerTransport;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.IndexingPressure;
|
||||
import org.elasticsearch.index.engine.CommitStats;
|
||||
import org.elasticsearch.index.engine.DocIdSeqNoAndSource;
|
||||
import org.elasticsearch.index.engine.Engine;
|
||||
|
@ -105,6 +105,7 @@ import org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache;
|
|||
import org.elasticsearch.indices.recovery.RecoverySettings;
|
||||
import org.elasticsearch.node.MockNode;
|
||||
import org.elasticsearch.node.Node;
|
||||
import org.elasticsearch.node.NodeRoleSettings;
|
||||
import org.elasticsearch.node.NodeService;
|
||||
import org.elasticsearch.node.NodeValidationException;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
|
@ -1145,7 +1146,13 @@ public final class InternalTestCluster extends TestCluster {
|
|||
} else {
|
||||
builder.put(NetworkModule.TRANSPORT_TYPE_SETTING.getKey(), getTestTransportType());
|
||||
}
|
||||
TransportClient client = new MockTransportClient(builder.build(), plugins);
|
||||
/*
|
||||
* The node.roles setting does not make sense for the transport client, filter it. If the transport client were not deprecated
|
||||
* we would probably want to invest in infrastructure to mark a setting as not applicable to the transport client and then
|
||||
* filter all such settings here.
|
||||
*/
|
||||
final Settings finalSettings = builder.build().filter(k -> k.equals(NodeRoleSettings.NODE_ROLES_SETTING.getKey()) == false);
|
||||
TransportClient client = new MockTransportClient(finalSettings, plugins);
|
||||
client.addTransportAddress(addr);
|
||||
return client;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue