Search in sources :

Example 51 with HazelcastProperties

use of com.hazelcast.spi.properties.HazelcastProperties in project hazelcast by hazelcast.

the class MulticastServiceTest method testSetInterfaceForced.

@Test
public void testSetInterfaceForced() throws Exception {
    Config config = createConfig(Boolean.TRUE);
    MulticastConfig multicastConfig = config.getNetworkConfig().getJoin().getMulticastConfig();
    MulticastSocket multicastSocket = mock(MulticastSocket.class);
    Address address = new Address("127.0.0.1", 5701);
    HazelcastProperties hzProperties = new HazelcastProperties(config);
    MulticastService.configureMulticastSocket(multicastSocket, address, hzProperties, multicastConfig, mock(ILogger.class));
    verify(multicastSocket).setInterface(address.getInetAddress());
}
Also used : MulticastSocket(java.net.MulticastSocket) HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) Address(com.hazelcast.cluster.Address) InetSocketAddress(java.net.InetSocketAddress) InetAddress(java.net.InetAddress) Config(com.hazelcast.config.Config) MulticastConfig(com.hazelcast.config.MulticastConfig) JoinConfig(com.hazelcast.config.JoinConfig) MulticastConfig(com.hazelcast.config.MulticastConfig) ILogger(com.hazelcast.logging.ILogger) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 52 with HazelcastProperties

use of com.hazelcast.spi.properties.HazelcastProperties in project hazelcast by hazelcast.

the class MulticastServiceTest method testSetInterfaceDefaultWhenNonLoopbackAddrAndDefaultLoopbackMode.

/**
 * Verifes the {@link MulticastSocket#setInterface(InetAddress)} is called by default if non-loopback address is used.
 * This is a regression test for the <a href="https://github.com/hazelcast/hazelcast/issues/19192">issue #19192</a>
 * (hit on Mac OS).
 */
@Test
public void testSetInterfaceDefaultWhenNonLoopbackAddrAndDefaultLoopbackMode() throws Exception {
    Config config = createConfig(null);
    MulticastConfig multicastConfig = config.getNetworkConfig().getJoin().getMulticastConfig();
    MulticastSocket multicastSocket = mock(MulticastSocket.class);
    Address address = new Address("10.0.0.2", 5701);
    HazelcastProperties hzProperties = new HazelcastProperties(config);
    MulticastService.configureMulticastSocket(multicastSocket, address, hzProperties, multicastConfig, mock(ILogger.class));
    verify(multicastSocket).setInterface(address.getInetAddress());
}
Also used : MulticastSocket(java.net.MulticastSocket) HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) Address(com.hazelcast.cluster.Address) InetSocketAddress(java.net.InetSocketAddress) InetAddress(java.net.InetAddress) Config(com.hazelcast.config.Config) MulticastConfig(com.hazelcast.config.MulticastConfig) JoinConfig(com.hazelcast.config.JoinConfig) MulticastConfig(com.hazelcast.config.MulticastConfig) ILogger(com.hazelcast.logging.ILogger) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 53 with HazelcastProperties

use of com.hazelcast.spi.properties.HazelcastProperties in project hazelcast by hazelcast.

the class MulticastServiceTest method testMulticastParams.

@Test
public void testMulticastParams() throws Exception {
    Config config = createConfig(null);
    MulticastConfig multicastConfig = config.getNetworkConfig().getJoin().getMulticastConfig();
    MulticastSocket multicastSocket = mock(MulticastSocket.class);
    Address address = new Address("10.0.0.2", 5701);
    HazelcastProperties hzProperties = new HazelcastProperties(config);
    MulticastService.configureMulticastSocket(multicastSocket, address, hzProperties, multicastConfig, mock(ILogger.class));
    verify(multicastSocket).bind(new InetSocketAddress(multicastConfig.getMulticastPort()));
    verify(multicastSocket).setTimeToLive(multicastConfig.getMulticastTimeToLive());
    verify(multicastSocket, never()).setLoopbackMode(anyBoolean());
    verify(multicastSocket).joinGroup(InetAddress.getByName(multicastConfig.getMulticastGroup()));
}
Also used : MulticastSocket(java.net.MulticastSocket) HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) Address(com.hazelcast.cluster.Address) InetSocketAddress(java.net.InetSocketAddress) InetAddress(java.net.InetAddress) Config(com.hazelcast.config.Config) MulticastConfig(com.hazelcast.config.MulticastConfig) JoinConfig(com.hazelcast.config.JoinConfig) InetSocketAddress(java.net.InetSocketAddress) MulticastConfig(com.hazelcast.config.MulticastConfig) ILogger(com.hazelcast.logging.ILogger) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 54 with HazelcastProperties

use of com.hazelcast.spi.properties.HazelcastProperties in project hazelcast by hazelcast.

the class SelectWithSelectorFix_NioNetworkingFactory method create.

@Override
public NioNetworking create(final MockServerContext serverContext, MetricsRegistry metricsRegistry) {
    HazelcastProperties properties = serverContext.properties();
    LoggingService loggingService = serverContext.loggingService;
    return new NioNetworking(new NioNetworking.Context().loggingService(loggingService).metricsRegistry(metricsRegistry).threadNamePrefix(serverContext.getHazelcastName()).errorHandler(new TcpServerConnectionChannelErrorHandler(loggingService.getLogger(TcpServerConnectionChannelErrorHandler.class))).inputThreadCount(properties.getInteger(IO_INPUT_THREAD_COUNT)).outputThreadCount(properties.getInteger(IO_OUTPUT_THREAD_COUNT)).balancerIntervalSeconds(properties.getInteger(IO_BALANCER_INTERVAL_SECONDS)).selectorMode(SelectorMode.SELECT_WITH_FIX).selectorWorkaroundTest(true));
}
Also used : MockServerContext(com.hazelcast.internal.server.MockServerContext) HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) TcpServerConnectionChannelErrorHandler(com.hazelcast.internal.server.tcp.TcpServerConnectionChannelErrorHandler) LoggingService(com.hazelcast.logging.LoggingService)

Example 55 with HazelcastProperties

use of com.hazelcast.spi.properties.HazelcastProperties in project hazelcast by hazelcast.

the class TaskletExecutionServiceTest method before.

@Before
public void before() {
    executor = Executors.newCachedThreadPool();
    NodeEngineImpl neMock = mock(NodeEngineImpl.class);
    HazelcastInstance hzMock = mock(HazelcastInstance.class);
    when(neMock.getHazelcastInstance()).thenReturn(hzMock);
    when(hzMock.getName()).thenReturn("test-hz-instance");
    ExecutionService es = mock(ExecutionService.class);
    when(neMock.getExecutionService()).thenReturn(es);
    when(es.submit(eq(TASKLET_INIT_CLOSE_EXECUTOR_NAME), any(Runnable.class))).then(invocationOnMock -> executor.submit(invocationOnMock.<Runnable>getArgument(1)));
    LoggingService loggingService = mock(LoggingService.class);
    when(neMock.getLoggingService()).thenReturn(loggingService);
    when(loggingService.getLogger(TaskletExecutionService.class)).thenReturn(Logger.getLogger(TaskletExecutionService.class));
    MetricsRegistryImpl metricsRegistry = new MetricsRegistryImpl(mock(ILogger.class), ProbeLevel.INFO);
    when(neMock.getMetricsRegistry()).thenReturn(metricsRegistry);
    HazelcastProperties properties = new HazelcastProperties(new Properties());
    tes = new TaskletExecutionService(neMock, THREAD_COUNT, properties);
    classLoaderMock = mock(ClassLoader.class);
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) HazelcastInstance(com.hazelcast.core.HazelcastInstance) LoggingService(com.hazelcast.logging.LoggingService) MetricsRegistryImpl(com.hazelcast.internal.metrics.impl.MetricsRegistryImpl) ILogger(com.hazelcast.logging.ILogger) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService) Properties(java.util.Properties) HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) Before(org.junit.Before)

Aggregations

HazelcastProperties (com.hazelcast.spi.properties.HazelcastProperties)71 Config (com.hazelcast.config.Config)31 QuickTest (com.hazelcast.test.annotation.QuickTest)29 Test (org.junit.Test)29 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)25 ILogger (com.hazelcast.logging.ILogger)15 Address (com.hazelcast.cluster.Address)11 JoinConfig (com.hazelcast.config.JoinConfig)8 MulticastConfig (com.hazelcast.config.MulticastConfig)8 InetAddress (java.net.InetAddress)8 InetSocketAddress (java.net.InetSocketAddress)8 MulticastSocket (java.net.MulticastSocket)8 Before (org.junit.Before)8 ExecutionService (com.hazelcast.spi.impl.executionservice.ExecutionService)7 Properties (java.util.Properties)7 Node (com.hazelcast.instance.impl.Node)4 LoggingService (com.hazelcast.logging.LoggingService)4 MapConfig (com.hazelcast.config.MapConfig)3 TcpServerConnectionChannelErrorHandler (com.hazelcast.internal.server.tcp.TcpServerConnectionChannelErrorHandler)3 ClientConfig (com.hazelcast.client.config.ClientConfig)2