Search in sources :

Example 1 with ServerConnectionManager

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

the class TcpIpJoiner method joinViaTargetMember.

private void joinViaTargetMember(Address targetAddress, long maxJoinMillis) {
    try {
        if (targetAddress == null) {
            throw new IllegalArgumentException("Invalid target address: NULL");
        }
        if (logger.isFineEnabled()) {
            logger.fine("Joining over target member " + targetAddress);
        }
        if (targetAddress.equals(node.getThisAddress()) || isLocalAddress(targetAddress)) {
            clusterJoinManager.setThisMemberAsMaster();
            return;
        }
        long joinStartTime = Clock.currentTimeMillis();
        Connection connection;
        while (shouldRetry() && (Clock.currentTimeMillis() - joinStartTime < maxJoinMillis)) {
            ServerConnectionManager connectionManager = node.getServer().getConnectionManager(MEMBER);
            connection = connectionManager.getOrConnect(targetAddress);
            if (connection == null) {
                connectionManager.blockOnConnect(targetAddress, JOIN_RETRY_WAIT_TIME, 0);
                continue;
            }
            if (logger.isFineEnabled()) {
                logger.fine("Sending joinRequest " + targetAddress);
            }
            clusterJoinManager.sendJoinRequest(targetAddress);
            if (!clusterService.isJoined()) {
                clusterService.blockOnJoin(JOIN_RETRY_WAIT_TIME);
            }
        }
    } catch (final Exception e) {
        logger.warning(e);
    }
}
Also used : ServerConnectionManager(com.hazelcast.internal.server.ServerConnectionManager) Connection(com.hazelcast.internal.nio.Connection) InvalidAddressException(com.hazelcast.internal.util.AddressUtil.InvalidAddressException) UnknownHostException(java.net.UnknownHostException)

Example 2 with ServerConnectionManager

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

the class PacketDispatcher method accept.

@Override
public void accept(Packet packet) {
    try {
        switch(packet.getPacketType()) {
            case OPERATION:
                if (packet.isFlagRaised(FLAG_OP_RESPONSE)) {
                    responseHandler.accept(packet);
                } else if (packet.isFlagRaised(FLAG_OP_CONTROL)) {
                    invocationMonitor.accept(packet);
                } else {
                    operationExecutor.accept(packet);
                }
                break;
            case EVENT:
                eventService.accept(packet);
                break;
            case SERVER_CONTROL:
                ServerConnection connection = packet.getConn();
                ServerConnectionManager connectionManager = connection.getConnectionManager();
                connectionManager.accept(packet);
                break;
            case JET:
                jetServiceBackend.accept(packet);
                break;
            default:
                logger.severe("Header flags [" + Integer.toBinaryString(packet.getFlags()) + "] specify an undefined packet type " + packet.getPacketType().name());
        }
    } catch (Throwable t) {
        inspectOutOfMemoryError(t);
        logger.severe("Failed to process: " + packet, t);
    }
}
Also used : ServerConnectionManager(com.hazelcast.internal.server.ServerConnectionManager) ServerConnection(com.hazelcast.internal.server.ServerConnection)

Example 3 with ServerConnectionManager

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

the class TextCommandServiceImpl method getStats.

@Override
public Stats getStats() {
    Stats stats = new Stats();
    stats.setUptime((int) ((Clock.currentTimeMillis() - startTime) / MILLIS_TO_SECONDS));
    stats.setCmdGet(getMisses.get() + getHits.get());
    stats.setCmdSet(sets.get());
    stats.setCmdTouch(touches.get());
    stats.setGetHits(getHits.get());
    stats.setGetMisses(getMisses.get());
    stats.setDeleteHits(deleteHits.get());
    stats.setDeleteMisses(deleteMisses.get());
    stats.setIncrHits(incrementHits.get());
    stats.setIncrMisses(incrementMisses.get());
    stats.setDecrHits(decrementHits.get());
    stats.setDecrMisses(decrementMisses.get());
    Server server = node.getServer();
    ServerConnectionManager cm = server.getConnectionManager(MEMCACHE);
    int memcachedCount = cm == null ? 0 : cm.connectionCount(c -> Protocols.MEMCACHE.equals(c.getConnectionType()));
    stats.setCurrConnections(memcachedCount);
    stats.setTotalConnections(server.connectionCount());
    return stats;
}
Also used : Clock(com.hazelcast.internal.util.Clock) ADD(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.ADD) RestCallCollector(com.hazelcast.internal.ascii.rest.RestCallCollector) TextEncoder(com.hazelcast.internal.nio.ascii.TextEncoder) Thread.currentThread(java.lang.Thread.currentThread) StatsCommandProcessor(com.hazelcast.internal.ascii.memcache.StatsCommandProcessor) HttpPostCommandProcessor(com.hazelcast.internal.ascii.rest.HttpPostCommandProcessor) ByteBuffer(java.nio.ByteBuffer) GET_END(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.GET_END) UNKNOWN(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.UNKNOWN) OutOfMemoryErrorDispatcher(com.hazelcast.instance.impl.OutOfMemoryErrorDispatcher) HTTP_POST(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.HTTP_POST) EmptyStatement.ignore(com.hazelcast.internal.util.EmptyStatement.ignore) GetCommandProcessor(com.hazelcast.internal.ascii.memcache.GetCommandProcessor) Map(java.util.Map) HTTP_GET(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.HTTP_GET) BULK_GET(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.BULK_GET) TouchCommandProcessor(com.hazelcast.internal.ascii.memcache.TouchCommandProcessor) Set(java.util.Set) Server(com.hazelcast.internal.server.Server) BlockingQueue(java.util.concurrent.BlockingQueue) ThreadUtil.createThreadName(com.hazelcast.internal.util.ThreadUtil.createThreadName) Node(com.hazelcast.instance.impl.Node) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) ERROR_CLIENT(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.ERROR_CLIENT) HttpDeleteCommandProcessor(com.hazelcast.internal.ascii.rest.HttpDeleteCommandProcessor) TOUCH(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.TOUCH) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) BulkGetCommandProcessor(com.hazelcast.internal.ascii.memcache.BulkGetCommandProcessor) REPLACE(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.REPLACE) INCREMENT(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.INCREMENT) VersionCommandProcessor(com.hazelcast.internal.ascii.memcache.VersionCommandProcessor) APPEND(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.APPEND) SET(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.SET) SimpleCommandProcessor(com.hazelcast.internal.ascii.memcache.SimpleCommandProcessor) ERROR_SERVER(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.ERROR_SERVER) Protocols(com.hazelcast.internal.nio.Protocols) PREPEND(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.PREPEND) DeleteCommandProcessor(com.hazelcast.internal.ascii.memcache.DeleteCommandProcessor) ILogger(com.hazelcast.logging.ILogger) STATS(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.STATS) Stats(com.hazelcast.internal.ascii.memcache.Stats) HTTP_HEAD(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.HTTP_HEAD) HTTP_PUT(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.HTTP_PUT) EntryConverter(com.hazelcast.internal.ascii.memcache.EntryConverter) SetCommandProcessor(com.hazelcast.internal.ascii.memcache.SetCommandProcessor) ServerConnectionManager(com.hazelcast.internal.server.ServerConnectionManager) HazelcastInstance(com.hazelcast.core.HazelcastInstance) HttpHeadCommandProcessor(com.hazelcast.internal.ascii.rest.HttpHeadCommandProcessor) Data(com.hazelcast.internal.serialization.Data) QUIT(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.QUIT) VERSION(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.VERSION) NO_OP(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.NO_OP) DECREMENT(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.DECREMENT) TimeUnit(java.util.concurrent.TimeUnit) MEMCACHE(com.hazelcast.instance.EndpointQualifier.MEMCACHE) AtomicLong(java.util.concurrent.atomic.AtomicLong) GET(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.GET) ErrorCommandProcessor(com.hazelcast.internal.ascii.memcache.ErrorCommandProcessor) RestValue(com.hazelcast.internal.ascii.rest.RestValue) HttpGetCommandProcessor(com.hazelcast.internal.ascii.rest.HttpGetCommandProcessor) IncrementCommandProcessor(com.hazelcast.internal.ascii.memcache.IncrementCommandProcessor) HTTP_DELETE(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.HTTP_DELETE) DELETE(com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.DELETE) IMap(com.hazelcast.map.IMap) Server(com.hazelcast.internal.server.Server) ServerConnectionManager(com.hazelcast.internal.server.ServerConnectionManager) Stats(com.hazelcast.internal.ascii.memcache.Stats)

Example 4 with ServerConnectionManager

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

the class MembershipUpdateTest method connectionsToTerminatedMember_shouldBeClosed.

@Test
public void connectionsToTerminatedMember_shouldBeClosed() {
    HazelcastInstance hz1 = factory.newHazelcastInstance();
    HazelcastInstance hz2 = factory.newHazelcastInstance();
    HazelcastInstance hz3 = factory.newHazelcastInstance();
    assertClusterSizeEventually(3, hz1, hz2, hz3);
    Address target = getAddress(hz2);
    hz2.getLifecycleService().terminate();
    assertClusterSizeEventually(2, hz1, hz3);
    assertNull(getConnectionManager(hz1).get(target));
    ServerConnectionManager cm3 = getConnectionManager(hz3);
    assertTrueEventually(() -> assertNull(cm3.get(target)));
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastInstanceFactory.newHazelcastInstance(com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance) Address(com.hazelcast.cluster.Address) Accessors.getAddress(com.hazelcast.test.Accessors.getAddress) ServerConnectionManager(com.hazelcast.internal.server.ServerConnectionManager) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with ServerConnectionManager

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

the class IOBalancerStressTest method debug.

private StringBuilder debug(HazelcastInstance hz) {
    TcpServer networkingService = (TcpServer) getNode(hz).getServer();
    NioNetworking networking = (NioNetworking) networkingService.getNetworking();
    ServerConnectionManager cm = getNode(hz).getServer().getConnectionManager(EndpointQualifier.MEMBER);
    StringBuilder sb = new StringBuilder();
    sb.append("in owners\n");
    for (NioThread in : networking.getInputThreads()) {
        sb.append(in).append(": ").append(in.getEventCount()).append("\n");
        for (ServerConnection connection : cm.getConnections()) {
            TcpServerConnection tcpConnection = (TcpServerConnection) connection;
            NioInboundPipeline inboundPipeline = ((NioChannel) tcpConnection.getChannel()).inboundPipeline();
            if (inboundPipeline.owner() == in) {
                sb.append("\t").append(inboundPipeline).append(" load: ").append(inboundPipeline.load()).append("\n");
            }
        }
    }
    sb.append("out owners\n");
    for (NioThread in : networking.getOutputThreads()) {
        sb.append(in).append(": ").append(in.getEventCount()).append("\n");
        for (ServerConnection connection : cm.getConnections()) {
            TcpServerConnection tcpConnection = (TcpServerConnection) connection;
            NioOutboundPipeline outboundPipeline = ((NioChannel) tcpConnection.getChannel()).outboundPipeline();
            if (outboundPipeline.owner() == in) {
                sb.append("\t").append(outboundPipeline).append(" load:").append(outboundPipeline.load()).append("\n");
            }
        }
    }
    return sb;
}
Also used : NioThread(com.hazelcast.internal.networking.nio.NioThread) ServerConnectionManager(com.hazelcast.internal.server.ServerConnectionManager) NioChannel(com.hazelcast.internal.networking.nio.NioChannel) ServerConnection(com.hazelcast.internal.server.ServerConnection) TcpServerConnection(com.hazelcast.internal.server.tcp.TcpServerConnection) NioNetworking(com.hazelcast.internal.networking.nio.NioNetworking) NioOutboundPipeline(com.hazelcast.internal.networking.nio.NioOutboundPipeline) TcpServer(com.hazelcast.internal.server.tcp.TcpServer) TcpServerConnection(com.hazelcast.internal.server.tcp.TcpServerConnection) NioInboundPipeline(com.hazelcast.internal.networking.nio.NioInboundPipeline)

Aggregations

ServerConnectionManager (com.hazelcast.internal.server.ServerConnectionManager)11 Address (com.hazelcast.cluster.Address)3 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 ServerConnection (com.hazelcast.internal.server.ServerConnection)3 Node (com.hazelcast.instance.impl.Node)2 Packet (com.hazelcast.internal.nio.Packet)2 Test (org.junit.Test)2 ClusterState (com.hazelcast.cluster.ClusterState)1 CPGroup (com.hazelcast.cp.CPGroup)1 CPGroupId (com.hazelcast.cp.CPGroupId)1 CPMember (com.hazelcast.cp.CPMember)1 CPSubsystem (com.hazelcast.cp.CPSubsystem)1 CPSubsystemManagementService (com.hazelcast.cp.CPSubsystemManagementService)1 CPSession (com.hazelcast.cp.session.CPSession)1 CLIENT (com.hazelcast.instance.EndpointQualifier.CLIENT)1 MEMCACHE (com.hazelcast.instance.EndpointQualifier.MEMCACHE)1 HazelcastInstanceFactory.newHazelcastInstance (com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance)1 NodeState (com.hazelcast.instance.impl.NodeState)1 OutOfMemoryErrorDispatcher (com.hazelcast.instance.impl.OutOfMemoryErrorDispatcher)1 ADD (com.hazelcast.internal.ascii.TextCommandConstants.TextCommandType.ADD)1