protected bool ReceiveSocketPreample(Socket sock, bool expectProxiedConnection, out GrainId client) { client = null; if (Cts.IsCancellationRequested) { return(false); } if (!ReadConnectionPreamble(sock, out client)) { return(false); } if (Log.IsVerbose2) { Log.Verbose2(ErrorCode.MessageAcceptor_Connection, "Received connection from {0} at source address {1}", client, sock.RemoteEndPoint.ToString()); } if (expectProxiedConnection) { // Proxied Gateway Connection - must have sender id if (client.Equals(Constants.SiloDirectConnectionId)) { Log.Error(ErrorCode.MessageAcceptor_NotAProxiedConnection, string.Format("Gateway received unexpected non-proxied connection from {0} at source address {1}", client, sock.RemoteEndPoint)); return(false); } } else { // Direct connection - should not have sender id if (!client.Equals(Constants.SiloDirectConnectionId)) { Log.Error(ErrorCode.MessageAcceptor_UnexpectedProxiedConnection, string.Format("Silo received unexpected proxied connection from {0} at source address {1}", client, sock.RemoteEndPoint)); return(false); } } lock (Lockable) { OpenReceiveSockets.Add(sock); } return(true); }
private void RunClientMessagePump(CancellationToken ct) { incomingMessagesThreadTimeTracking?.OnStartExecution(); while (listenForMessages) { var message = transport.WaitMessage(Message.Categories.Application, ct); if (message == null) // if wait was cancelled { break; } // when we receive the first message, we update the // clientId for this client because it may have been modified to // include the cluster name if (!firstMessageReceived) { firstMessageReceived = true; if (!handshakeClientId.Equals(message.TargetGrain)) { clientId = message.TargetGrain; transport.UpdateClientId(clientId); CurrentActivationAddress = ActivationAddress.GetAddress(transport.MyAddress, clientId, CurrentActivationAddress.Activation); } else { clientId = handshakeClientId; } } switch (message.Direction) { case Message.Directions.Response: { ReceiveResponse(message); break; } case Message.Directions.OneWay: case Message.Directions.Request: { this.localObjects.Dispatch(message); break; } default: logger.Error(ErrorCode.Runtime_Error_100327, $"Message not supported: {message}."); break; } } incomingMessagesThreadTimeTracking?.OnStopExecution(); }
private void HandleMessage(Message message) { // when we receive the first message, we update the // clientId for this client because it may have been modified to // include the cluster name if (!firstMessageReceived) { firstMessageReceived = true; if (!handshakeClientId.Equals(message.TargetGrain)) { clientId = message.TargetGrain; transport.UpdateClientId(clientId); CurrentActivationAddress = ActivationAddress.GetAddress(transport.MyAddress, clientId, CurrentActivationAddress.Activation); } else { clientId = handshakeClientId; } } switch (message.Direction) { case Message.Directions.Response: { ReceiveResponse(message); break; } case Message.Directions.OneWay: case Message.Directions.Request: { this.localObjects.Dispatch(message); break; } default: logger.Error(ErrorCode.Runtime_Error_100327, $"Message not supported: {message}."); break; } }
private void RunClientMessagePump(CancellationToken ct) { if (StatisticsCollector.CollectThreadTimeTrackingStats) { incomingMessagesThreadTimeTracking.OnStartExecution(); } while (listenForMessages) { var message = transport.WaitMessage(Message.Categories.Application, ct); if (message == null) // if wait was cancelled { break; } #if TRACK_DETAILED_STATS if (StatisticsCollector.CollectThreadTimeTrackingStats) { incomingMessagesThreadTimeTracking.OnStartProcessing(); } #endif // when we receive the first message, we update the // clientId for this client because it may have been modified to // include the cluster name if (!firstMessageReceived) { firstMessageReceived = true; if (!handshakeClientId.Equals(message.TargetGrain)) { clientId = message.TargetGrain; transport.UpdateClientId(clientId); CurrentActivationAddress = ActivationAddress.GetAddress(transport.MyAddress, clientId, CurrentActivationAddress.Activation); } else { clientId = handshakeClientId; } } switch (message.Direction) { case Message.Directions.Response: { ReceiveResponse(message); break; } case Message.Directions.OneWay: case Message.Directions.Request: { this.DispatchToLocalObject(message); break; } default: logger.Error(ErrorCode.Runtime_Error_100327, String.Format("Message not supported: {0}.", message)); break; } #if TRACK_DETAILED_STATS if (StatisticsCollector.CollectThreadTimeTrackingStats) { incomingMessagesThreadTimeTracking.OnStopProcessing(); incomingMessagesThreadTimeTracking.IncrementNumberOfProcessed(); } #endif } if (StatisticsCollector.CollectThreadTimeTrackingStats) { incomingMessagesThreadTimeTracking.OnStopExecution(); } }
protected bool ReceiveSocketPreample(Socket sock, bool expectProxiedConnection, out GrainId client) { client = null; if (Cts.IsCancellationRequested) return false; if (!ReadConnectionPreemble(sock, out client)) { return false; } if (Log.IsVerbose2) Log.Verbose2(ErrorCode.MessageAcceptor_Connection, "Received connection from {0} at source address {1}", client, sock.RemoteEndPoint.ToString()); if (expectProxiedConnection) { // Proxied Gateway Connection - must have sender id if (client.Equals(Constants.SiloDirectConnectionId)) { Log.Error(ErrorCode.MessageAcceptor_NotAProxiedConnection, string.Format("Gateway received unexpected non-proxied connection from {0} at source address {1}", client, sock.RemoteEndPoint)); return false; } } else { // Direct connection - should not have sender id if (!client.Equals(Constants.SiloDirectConnectionId)) { Log.Error(ErrorCode.MessageAcceptor_UnexpectedProxiedConnection, string.Format("Silo received unexpected proxied connection from {0} at source address {1}", client, sock.RemoteEndPoint)); return false; } } lock (Lockable) { OpenReceiveSockets.Add(sock); } return true; }