Search in sources :

Example 1 with MockServerContext

use of com.hazelcast.internal.server.MockServerContext in project hazelcast by hazelcast.

the class TcpServerConnection_AbstractTest method newMockTcpServer.

protected TcpServer newMockTcpServer(MetricsRegistry metricsRegistry) throws Exception {
    MockServerContext serverContext = null;
    while (serverContext == null) {
        try {
            serverContext = new MockServerContext(portNumber++, UuidUtil.newUnsecureUUID());
        } catch (IOException e) {
            if (portNumber >= PORT_NUMBER_UPPER_LIMIT) {
                throw e;
            }
        }
    }
    ServerSocketRegistry registry = new ServerSocketRegistry(singletonMap(MEMBER, serverContext.serverSocketChannel), true);
    LocalAddressRegistry addressRegistry = new LocalAddressRegistry(logger);
    MockServerContext finalServiceContext = serverContext;
    return new TcpServer(null, serverContext, registry, addressRegistry, metricsRegistry, networkingFactory.create(serverContext, metricsRegistry), qualifier -> new UnifiedChannelInitializer(finalServiceContext));
}
Also used : IOException(java.io.IOException) MockServerContext(com.hazelcast.internal.server.MockServerContext)

Example 2 with MockServerContext

use of com.hazelcast.internal.server.MockServerContext 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)

Aggregations

MockServerContext (com.hazelcast.internal.server.MockServerContext)2 TcpServerConnectionChannelErrorHandler (com.hazelcast.internal.server.tcp.TcpServerConnectionChannelErrorHandler)1 LoggingService (com.hazelcast.logging.LoggingService)1 HazelcastProperties (com.hazelcast.spi.properties.HazelcastProperties)1 IOException (java.io.IOException)1