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));
}
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));
}
Aggregations