Search in sources :

Example 1 with NonBlockingIOThreadingModel

use of com.hazelcast.internal.networking.nonblocking.NonBlockingIOThreadingModel in project hazelcast by hazelcast.

the class DefaultNodeContext method createTcpIpConnectionThreadingModel.

private IOThreadingModel createTcpIpConnectionThreadingModel(Node node, NodeIOService ioService) {
    boolean spinning = Boolean.getBoolean("hazelcast.io.spinning");
    LoggingServiceImpl loggingService = node.loggingService;
    SocketWriterInitializerImpl socketWriterInitializer = new SocketWriterInitializerImpl(loggingService.getLogger(SocketWriterInitializerImpl.class));
    SocketReaderInitializerImpl socketReaderInitializer = new SocketReaderInitializerImpl(loggingService.getLogger(SocketReaderInitializerImpl.class));
    if (spinning) {
        return new SpinningIOThreadingModel(loggingService, node.getHazelcastThreadGroup(), ioService.getIoOutOfMemoryHandler(), socketWriterInitializer, socketReaderInitializer);
    } else {
        return new NonBlockingIOThreadingModel(loggingService, node.nodeEngine.getMetricsRegistry(), node.getHazelcastThreadGroup(), ioService.getIoOutOfMemoryHandler(), ioService.getInputSelectorThreadCount(), ioService.getOutputSelectorThreadCount(), ioService.getBalancerIntervalSeconds(), socketWriterInitializer, socketReaderInitializer);
    }
}
Also used : SpinningIOThreadingModel(com.hazelcast.internal.networking.spinning.SpinningIOThreadingModel) SocketReaderInitializerImpl(com.hazelcast.nio.tcp.SocketReaderInitializerImpl) LoggingServiceImpl(com.hazelcast.logging.LoggingServiceImpl) SocketWriterInitializerImpl(com.hazelcast.nio.tcp.SocketWriterInitializerImpl) NonBlockingIOThreadingModel(com.hazelcast.internal.networking.nonblocking.NonBlockingIOThreadingModel)

Example 2 with NonBlockingIOThreadingModel

use of com.hazelcast.internal.networking.nonblocking.NonBlockingIOThreadingModel in project hazelcast by hazelcast.

the class ClientConnectionManagerImpl method initIOThreads.

protected void initIOThreads(HazelcastClientInstanceImpl client) {
    HazelcastProperties properties = client.getProperties();
    boolean directBuffer = properties.getBoolean(SOCKET_CLIENT_BUFFER_DIRECT);
    SSLConfig sslConfig = client.getClientConfig().getNetworkConfig().getSSLConfig();
    boolean sslEnabled = sslConfig != null && sslConfig.isEnabled();
    int configuredInputThreads = properties.getInteger(ClientProperty.IO_INPUT_THREAD_COUNT);
    int configuredOutputThreads = properties.getInteger(ClientProperty.IO_OUTPUT_THREAD_COUNT);
    int inputThreads;
    if (configuredInputThreads == -1) {
        inputThreads = sslEnabled ? DEFAULT_SSL_THREAD_COUNT : 1;
    } else {
        inputThreads = configuredInputThreads;
    }
    int outputThreads;
    if (configuredOutputThreads == -1) {
        outputThreads = sslEnabled ? DEFAULT_SSL_THREAD_COUNT : 1;
    } else {
        outputThreads = configuredOutputThreads;
    }
    ioThreadingModel = new NonBlockingIOThreadingModel(client.getLoggingService(), client.getMetricsRegistry(), new HazelcastThreadGroup(client.getName(), logger, client.getClientConfig().getClassLoader()), outOfMemoryHandler, inputThreads, outputThreads, properties.getInteger(ClientProperty.IO_BALANCER_INTERVAL_SECONDS), new ClientSocketWriterInitializer(getBufferSize(), directBuffer), new ClientSocketReaderInitializer(getBufferSize(), directBuffer));
}
Also used : HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) SSLConfig(com.hazelcast.config.SSLConfig) HazelcastThreadGroup(com.hazelcast.instance.HazelcastThreadGroup) NonBlockingIOThreadingModel(com.hazelcast.internal.networking.nonblocking.NonBlockingIOThreadingModel)

Example 3 with NonBlockingIOThreadingModel

use of com.hazelcast.internal.networking.nonblocking.NonBlockingIOThreadingModel in project hazelcast by hazelcast.

the class IOBalancerStressTest method debug.

public String debug(TcpIpConnectionManager connectionManager) {
    NonBlockingIOThreadingModel threadingModel = (NonBlockingIOThreadingModel) connectionManager.getIoThreadingModel();
    StringBuffer sb = new StringBuffer();
    sb.append("in selectors\n");
    for (NonBlockingIOThread in : threadingModel.getInputThreads()) {
        sb.append(in + ": " + in.getEventCount() + "\n");
        for (TcpIpConnection connection : connectionManager.getActiveConnections()) {
            NonBlockingSocketReader socketReader = (NonBlockingSocketReader) connection.getSocketReader();
            if (socketReader.getOwner() == in) {
                sb.append("\t" + socketReader + " eventCount:" + socketReader.getEventCount() + "\n");
            }
        }
    }
    sb.append("out selectors\n");
    for (NonBlockingIOThread in : threadingModel.getOutputThreads()) {
        sb.append(in + ": " + in.getEventCount() + "\n");
        for (TcpIpConnection connection : connectionManager.getActiveConnections()) {
            NonBlockingSocketWriter socketWriter = (NonBlockingSocketWriter) connection.getSocketWriter();
            if (socketWriter.getOwner() == in) {
                sb.append("\t" + socketWriter + " eventCount:" + socketWriter.getEventCount() + "\n");
            }
        }
    }
    return sb.toString();
}
Also used : NonBlockingIOThread(com.hazelcast.internal.networking.nonblocking.NonBlockingIOThread) TcpIpConnection(com.hazelcast.nio.tcp.TcpIpConnection) NonBlockingSocketReader(com.hazelcast.internal.networking.nonblocking.NonBlockingSocketReader) NonBlockingSocketWriter(com.hazelcast.internal.networking.nonblocking.NonBlockingSocketWriter) NonBlockingIOThreadingModel(com.hazelcast.internal.networking.nonblocking.NonBlockingIOThreadingModel)

Aggregations

NonBlockingIOThreadingModel (com.hazelcast.internal.networking.nonblocking.NonBlockingIOThreadingModel)3 SSLConfig (com.hazelcast.config.SSLConfig)1 HazelcastThreadGroup (com.hazelcast.instance.HazelcastThreadGroup)1 NonBlockingIOThread (com.hazelcast.internal.networking.nonblocking.NonBlockingIOThread)1 NonBlockingSocketReader (com.hazelcast.internal.networking.nonblocking.NonBlockingSocketReader)1 NonBlockingSocketWriter (com.hazelcast.internal.networking.nonblocking.NonBlockingSocketWriter)1 SpinningIOThreadingModel (com.hazelcast.internal.networking.spinning.SpinningIOThreadingModel)1 LoggingServiceImpl (com.hazelcast.logging.LoggingServiceImpl)1 SocketReaderInitializerImpl (com.hazelcast.nio.tcp.SocketReaderInitializerImpl)1 SocketWriterInitializerImpl (com.hazelcast.nio.tcp.SocketWriterInitializerImpl)1 TcpIpConnection (com.hazelcast.nio.tcp.TcpIpConnection)1 HazelcastProperties (com.hazelcast.spi.properties.HazelcastProperties)1