Register possible node roles in transport client
The transport client needs to be told about the possible node roles. This commit does that.
This commit is contained in:
parent
3c73602524
commit
2bcc49424d
|
@ -27,6 +27,7 @@ import org.elasticsearch.action.ActionResponse;
|
|||
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;
|
||||
|
@ -67,6 +68,7 @@ import java.util.Arrays;
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -138,6 +140,14 @@ public abstract class TransportClient extends AbstractClient {
|
|||
.put(pluginsService.updatedSettings())
|
||||
.put(TransportSettings.FEATURE_PREFIX + "." + TRANSPORT_CLIENT_FEATURE, true)
|
||||
.build();
|
||||
final Set<DiscoveryNodeRole> possibleRoles = Stream.concat(
|
||||
DiscoveryNodeRole.BUILT_IN_ROLES.stream(),
|
||||
pluginsService.filterPlugins(Plugin.class)
|
||||
.stream()
|
||||
.map(Plugin::getRoles)
|
||||
.flatMap(Set::stream))
|
||||
.collect(Collectors.toSet());
|
||||
DiscoveryNode.setPossibleRoles(possibleRoles);
|
||||
final List<Closeable> resourcesToClose = new ArrayList<>();
|
||||
final ThreadPool threadPool = new ThreadPool(settings);
|
||||
resourcesToClose.add(() -> ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS));
|
||||
|
|
Loading…
Reference in New Issue