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