use of com.hazelcast.internal.server.ServerConnection in project hazelcast by hazelcast.
the class OperationRunnerImpl method run.
@Override
public boolean run(Packet packet) throws Exception {
long startNanos = System.nanoTime();
boolean publishCurrentTask = publishCurrentTask();
if (publishCurrentTask) {
currentTask = packet;
}
ServerConnection connection = packet.getConn();
Address caller = connection.getRemoteAddress();
UUID callerUuid = connection.getRemoteUuid();
Operation op = null;
try {
Object object = nodeEngine.toObject(packet);
op = (Operation) object;
op.setNodeEngine(nodeEngine);
setCallerAddress(op, caller);
setConnection(op, connection);
setCallerUuidIfNotSet(op, callerUuid);
setOperationResponseHandler(op);
if (!ensureValidMember(op)) {
return false;
}
if (publishCurrentTask) {
currentTask = null;
}
return run(op, startNanos);
} catch (Throwable throwable) {
// If exception happens we need to extract the callId from the bytes directly!
long callId = extractOperationCallId(packet);
outboundResponseHandler.send(connection.getConnectionManager(), caller, new ErrorResponse(throwable, callId, packet.isUrgent()));
logOperationDeserializationException(throwable, callId);
throw ExceptionUtil.rethrow(throwable);
} finally {
if (op != null) {
op.clearThreadContext();
}
if (publishCurrentTask) {
currentTask = null;
}
}
}
use of com.hazelcast.internal.server.ServerConnection in project hazelcast by hazelcast.
the class ClientEngineImpl method bind.
@Override
public boolean bind(final ClientEndpoint endpoint) {
if (!isClientAllowed(endpoint)) {
return false;
}
ServerConnection conn = endpoint.getConnection();
InetSocketAddress socketAddress = conn.getRemoteSocketAddress();
// socket address can be null if connection closed before bind
if (socketAddress != null) {
conn.setRemoteAddress(new Address(socketAddress));
}
if (endpointManager.registerEndpoint(endpoint)) {
// will be cleaned up by ClientHeartbeatMonitor#cleanupEndpointsWithDeadConnections later.
if (conn.getRemoteAddress() != null && endpoint.getUuid() != null) {
node.getServer().getConnectionManager(CLIENT).register(conn.getRemoteAddress(), endpoint.getUuid(), conn);
}
}
// Second check to catch concurrent change done via applySelector
if (!isClientAllowed(endpoint)) {
endpointManager.removeEndpoint(endpoint);
return false;
}
return true;
}
use of com.hazelcast.internal.server.ServerConnection in project hazelcast by hazelcast.
the class ClientEndpointManagerImpl method registerEndpoint.
@Override
public boolean registerEndpoint(ClientEndpoint endpoint) {
checkNotNull(endpoint, "endpoint can't be null");
final ServerConnection conn = endpoint.getConnection();
if (endpoints.putIfAbsent(conn, endpoint) != null) {
return false;
} else {
totalRegistrations.inc();
ClientEvent event = new ClientEvent(endpoint.getUuid(), ClientEventType.CONNECTED, endpoint.getSocketAddress(), endpoint.getClientType(), endpoint.getName(), endpoint.getLabels());
sendClientEvent(event);
return true;
}
}
use of com.hazelcast.internal.server.ServerConnection 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;
}
use of com.hazelcast.internal.server.ServerConnection in project hazelcast by hazelcast.
the class AuthenticationBaseMessageTask method prepareAuthenticatedClientMessage.
private ClientMessage prepareAuthenticatedClientMessage() {
ServerConnection connection = endpoint.getConnection();
setConnectionType();
endpoint.authenticated(clientUuid, credentials, clientVersion, clientMessage.getCorrelationId(), clientName, labels);
validateNodeStart();
final UUID clusterId = clientEngine.getClusterService().getClusterId();
// see AbstractMessageTask#acceptOnIncompleteStart
if (clusterId == null) {
throw new HazelcastInstanceNotActiveException("Hazelcast instance is not ready yet!");
}
if (!clientEngine.bind(endpoint)) {
return prepareNotAllowedInCluster();
}
logger.info("Received auth from " + connection + ", successfully authenticated, clientUuid: " + clientUuid + ", client name: " + clientName + ", client version: " + clientVersion);
final Address thisAddress = clientEngine.getThisAddress();
UUID uuid = clientEngine.getClusterService().getLocalMember().getUuid();
byte status = AUTHENTICATED.getId();
boolean clientFailoverSupported = nodeEngine.getNode().getNodeExtension().isClientFailoverSupported();
return encodeAuth(status, thisAddress, uuid, serializationService.getVersion(), clientEngine.getPartitionService().getPartitionCount(), clusterId, clientFailoverSupported);
}
Aggregations