Search in sources :

Example 16 with DiscoveryServiceProvider

use of com.hazelcast.spi.discovery.integration.DiscoveryServiceProvider in project hazelcast by hazelcast.

the class DiscoverySpiTest method testCustomDiscoveryService_whenDiscoveredNodes_isEmpty.

@Test
public void testCustomDiscoveryService_whenDiscoveredNodes_isEmpty() {
    Config config = new Config();
    config.setProperty(ClusterProperty.DISCOVERY_SPI_ENABLED.getName(), "true");
    final DiscoveryService discoveryService = mock(DiscoveryService.class);
    DiscoveryServiceProvider discoveryServiceProvider = new DiscoveryServiceProvider() {

        public DiscoveryService newDiscoveryService(DiscoveryServiceSettings arg0) {
            when(discoveryService.discoverNodes()).thenReturn(Collections.<DiscoveryNode>emptyList());
            return discoveryService;
        }
    };
    config.getNetworkConfig().getJoin().getDiscoveryConfig().setDiscoveryServiceProvider(discoveryServiceProvider);
    HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
    try {
        verify(discoveryService, atLeastOnce()).discoverNodes();
    } finally {
        instance.getLifecycleService().terminate();
    }
}
Also used : DiscoveryServiceProvider(com.hazelcast.spi.discovery.integration.DiscoveryServiceProvider) DefaultDiscoveryServiceProvider(com.hazelcast.spi.discovery.impl.DefaultDiscoveryServiceProvider) HazelcastInstance(com.hazelcast.core.HazelcastInstance) AwsConfig(com.hazelcast.config.AwsConfig) DiscoveryStrategyConfig(com.hazelcast.config.DiscoveryStrategyConfig) MulticastConfig(com.hazelcast.config.MulticastConfig) JoinConfig(com.hazelcast.config.JoinConfig) Config(com.hazelcast.config.Config) DiscoveryConfig(com.hazelcast.config.DiscoveryConfig) TcpIpConfig(com.hazelcast.config.TcpIpConfig) InterfacesConfig(com.hazelcast.config.InterfacesConfig) DiscoveryService(com.hazelcast.spi.discovery.integration.DiscoveryService) DefaultDiscoveryService(com.hazelcast.spi.discovery.impl.DefaultDiscoveryService) DiscoveryServiceSettings(com.hazelcast.spi.discovery.integration.DiscoveryServiceSettings) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

DiscoveryServiceProvider (com.hazelcast.spi.discovery.integration.DiscoveryServiceProvider)16 DefaultDiscoveryServiceProvider (com.hazelcast.spi.discovery.impl.DefaultDiscoveryServiceProvider)15 DiscoveryService (com.hazelcast.spi.discovery.integration.DiscoveryService)13 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)12 DefaultDiscoveryService (com.hazelcast.spi.discovery.impl.DefaultDiscoveryService)12 QuickTest (com.hazelcast.test.annotation.QuickTest)12 Test (org.junit.Test)12 DiscoveryServiceSettings (com.hazelcast.spi.discovery.integration.DiscoveryServiceSettings)11 ClientNetworkConfig (com.hazelcast.client.config.ClientNetworkConfig)10 ClientConfig (com.hazelcast.client.config.ClientConfig)8 InputStream (java.io.InputStream)7 XmlClientConfigBuilder (com.hazelcast.client.config.XmlClientConfigBuilder)6 DiscoveryStrategyConfig (com.hazelcast.config.DiscoveryStrategyConfig)6 JoinConfig (com.hazelcast.config.JoinConfig)6 ILogger (com.hazelcast.logging.ILogger)6 Config (com.hazelcast.config.Config)5 InterfacesConfig (com.hazelcast.config.InterfacesConfig)5 Field (java.lang.reflect.Field)5 SimpleDiscoveryNode (com.hazelcast.spi.discovery.SimpleDiscoveryNode)4 Address (com.hazelcast.cluster.Address)3