Search in sources :

Example 1 with DiscoveryPlugin

use of org.opensearch.plugins.DiscoveryPlugin in project OpenSearch by opensearch-project.

the class DiscoveryModuleTests method testJoinValidator.

public void testJoinValidator() {
    BiConsumer<DiscoveryNode, ClusterState> consumer = (a, b) -> {
    };
    DiscoveryModule module = newModule(Settings.builder().put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), DiscoveryModule.ZEN2_DISCOVERY_TYPE).build(), Collections.singletonList(new DiscoveryPlugin() {

        @Override
        public BiConsumer<DiscoveryNode, ClusterState> getJoinValidator() {
            return consumer;
        }
    }));
    Coordinator discovery = (Coordinator) module.getDiscovery();
    Collection<BiConsumer<DiscoveryNode, ClusterState>> onJoinValidators = discovery.getOnJoinValidators();
    assertEquals(2, onJoinValidators.size());
    assertTrue(onJoinValidators.contains(consumer));
}
Also used : Arrays(java.util.Arrays) ThreadPool(org.opensearch.threadpool.ThreadPool) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Version(org.opensearch.Version) ThreadContext(org.opensearch.common.util.concurrent.ThreadContext) MockTransportService(org.opensearch.test.transport.MockTransportService) Supplier(java.util.function.Supplier) NamedWriteableRegistry(org.opensearch.common.io.stream.NamedWriteableRegistry) ClusterState(org.opensearch.cluster.ClusterState) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) After(org.junit.After) Map(java.util.Map) RerouteService(org.opensearch.cluster.routing.RerouteService) BiConsumer(java.util.function.BiConsumer) Coordinator(org.opensearch.cluster.coordination.Coordinator) ClusterSettings(org.opensearch.common.settings.ClusterSettings) Before(org.junit.Before) ClusterApplier(org.opensearch.cluster.service.ClusterApplier) MasterService(org.opensearch.cluster.service.MasterService) OpenSearchTestCase(org.opensearch.test.OpenSearchTestCase) Collection(java.util.Collection) Settings(org.opensearch.common.settings.Settings) IOException(java.io.IOException) Mockito.when(org.mockito.Mockito.when) TransportService(org.opensearch.transport.TransportService) DiscoveryPlugin(org.opensearch.plugins.DiscoveryPlugin) IOUtils(org.opensearch.core.internal.io.IOUtils) GatewayMetaState(org.opensearch.gateway.GatewayMetaState) List(java.util.List) NetworkService(org.opensearch.common.network.NetworkService) Collections(java.util.Collections) Mockito.mock(org.mockito.Mockito.mock) ClusterState(org.opensearch.cluster.ClusterState) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) DiscoveryPlugin(org.opensearch.plugins.DiscoveryPlugin) Coordinator(org.opensearch.cluster.coordination.Coordinator) BiConsumer(java.util.function.BiConsumer)

Aggregations

IOException (java.io.IOException)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 BiConsumer (java.util.function.BiConsumer)1 Supplier (java.util.function.Supplier)1 After (org.junit.After)1 Before (org.junit.Before)1 Mockito.mock (org.mockito.Mockito.mock)1 Mockito.when (org.mockito.Mockito.when)1 Version (org.opensearch.Version)1 ClusterState (org.opensearch.cluster.ClusterState)1 Coordinator (org.opensearch.cluster.coordination.Coordinator)1 DiscoveryNode (org.opensearch.cluster.node.DiscoveryNode)1 RerouteService (org.opensearch.cluster.routing.RerouteService)1 ClusterApplier (org.opensearch.cluster.service.ClusterApplier)1 MasterService (org.opensearch.cluster.service.MasterService)1