public ChatClientNetChannel(IActorSystem<IRoomActor> rooms, ICallbacksGatewayNode callbacksNode, INetNode node, ITransportChannel transportChannel, IMessageSerializer serializer, ICoreEvents logger, INetNodeConfig config, IBufferPool bufferPool) : base(node, transportChannel, serializer, logger, config, bufferPool) { _rooms = rooms; _callbacksNode = callbacksNode; }
public void ActorActivated(INetNode node, ActorKey actorKey) { if (_logger.IsEnabled(LogEventLevel.Information)) { _logger.Information("actor:{@actorKey} is activated on node:{@node}", actorKey, node); } }
public void ConnectionHasTimedOut(INetNode node, IPEndPoint address) { if (_logger.IsEnabled(LogEventLevel.Warning)) { _logger.Warning("NetNode {@node} has failed to connect to {@address} within alloted time", node, address); } }
public void NetChannelRequestFailed(INetNode node, NetChannel channel, ErrorMessage error, Guid requestId, int durationMs) { if (_logger.IsEnabled(LogEventLevel.Warning)) { _logger.Warning("NetNode {@node} NetChannel {@channel} sent request failed with {@error} for {requestId} in {durationMs} ms", node, channel, error, requestId, durationMs); } }
public void NetChannelDisconnected(INetNode node, INetChannel channel) { if (_logger.IsEnabled(LogEventLevel.Debug)) { _logger.Debug("NetNode {@node} NetChannel {@channel} has disconnected", node, channel); } }
public void NetChannelRequestTimedOut(INetNode node, INetChannel channel, Message message, Guid requestId, int durationMs) { if (_logger.IsEnabled(LogEventLevel.Warning)) { _logger.Warning("NetChannel {@channel} has timed out within {durationMs} ms on sending request {@message} {requestId}", channel, durationMs, message, requestId); } }
public AsyncProcessingNetChannel(Func<IMessageProcessingPipeBuilder, IMessageProcessingPipeBuilder> configureProcesssingPipe, INetNode node, ITransportChannel transportChannel, IMessageSerializer serializer, ICoreEvents logger, INetNodeConfig config, IBufferPool bufferPool) : base(node, transportChannel, serializer, logger, config, bufferPool) { _pipeBuilder = configureProcesssingPipe(new MessageProcessingPipeBuilder()); _processor = _pipeBuilder.Build(); }
public void CantReplyToOneWayMessage(INetNode node, IOperationContext operation) { if (_logger.IsEnabled(LogEventLevel.Debug)) { _logger.Warning("NetChannel {@channel} is trying to reply to one way message {@message}", operation.ReplyChannel, operation.Message); } }
public void NetChannelIsDisposing(INetNode node, INetChannel channel) { if (_logger.IsEnabled(LogEventLevel.Debug)) { _logger.Debug("NetChannel {@channel} is closing", channel); } }
public void NodeUpdateLoopError(INetNode node, Exception exception) { if (_logger.IsEnabled(LogEventLevel.Error)) { _logger.Error("NetNode {@node} unexpected exception {@exception}", node, exception); } }
public NetChannel(INetNode node, ITransportChannel transportChannel, IMessageSerializer serializer, ICoreEvents logger, INetNodeConfig config, IBufferPool bufferPool) { _onOperationSubject = new Subject <OperationContext>(); _onDisconnectedSubject = new Subject <INetChannel>(); PendingOperationsByRequestId = new ConcurrentDictionary <Guid, PendingOperation>(); TransportChannel = transportChannel; var metricContext = Metric.Context(node.InstanceName); _receivedMessagesMeter = metricContext.Meter("ReceivedMessagesMeter", Unit.Requests); _sentMessagesMeter = metricContext.Meter("SentMessagesMeter", Unit.Requests); _requestsMeter = metricContext.Meter("SentRequestsMeter", Unit.Requests); _requestsFailedMeter = metricContext.Meter("SentRequestsFailedMeter", Unit.Requests); _requestDurationTimer = metricContext.Timer("SentRequestsDurationTimer", Unit.Requests, durationUnit: TimeUnit.Milliseconds); Node = node; Logger = logger; _config = config; _bufferPool = bufferPool; MessageSerializer = serializer; IsConnected = true; transportChannel.Bind(ProcessIncomingRequest, Dispose); }
public void OperationProcessed(INetNode node, INetChannel channel, IOperationContext operation) { if (_logger.IsEnabled(LogEventLevel.Information)) { _logger.Information("NetNode {@node} on NetChannel {@channel} processed {@operation}", node, channel, operation); } }
public void NodeUpdateLoopStarted(INetNode node) { if (_logger.IsEnabled(LogEventLevel.Information)) { _logger.Information("Update loop of NetNode {@node} has started", node); } }
public void NetChannelSentMessage(INetNode node, INetChannel channel, Message message) { if (_logger.IsEnabled(LogEventLevel.Debug)) { _logger.Debug("NetChannel {@channel} has sent message {@message}", channel, message); } }
private void HandleGamePacket(object sender, PacketEventArgs e) { INetNode node = (INetNode)sender; if (e.Type == PacketType.Connect) { if (e.Data.Length != 0) { return; } byte[] data = new byte [8]; BitConv.ToInt32(data, 0, nodes.IndexOf(node)); BitConv.ToInt32(data, 4, nodes.Count); node.SendPacket(PacketType.Accepted, data); } else if (e.Type == PacketType.DoomData) { if (e.Data.Length < 4) { return; } int nodeid = BitConv.FromInt32(e.Data, 0); if (nodeid < 0 || nodeid >= nodes.Count) { return; } byte[] data = new byte [e.Data.Length]; BitConv.ToInt32(data, 0, nodes.IndexOf(node)); Array.Copy(e.Data, 4, data, 4, e.Data.Length - 4); nodes[nodeid].SendPacket(PacketType.DoomData, data); } }
public void NodeStopped(INetNode node) { if (_logger.IsEnabled(LogEventLevel.Warning)) { _logger.Warning("NetNode {@node} has stopped", node); } }
public void ConnectingTo(INetNode node, IPEndPoint address) { if (_logger.IsEnabled(LogEventLevel.Debug)) { _logger.Debug("NetNode {@node} is trying to connect to {@address}", node, address); } }
public void OperationProcessingFailed(INetNode node, INetChannel channel, IOperationContext operation, Exception exception) { if (_logger.IsEnabled(LogEventLevel.Warning)) { _logger.Warning("NetNode {@node} on NetChannel {@channel} failed to process operation {@operation} with {@exception}", node, channel, operation, exception); } }
public void NetChannelRequestCompleted(INetNode node, INetChannel channel, Message message, Guid requestId, int durationMs) { if (_logger.IsEnabled(LogEventLevel.Information)) { _logger.Information("NetNode {@node} NetChannel {@channel} is received reply {@message} for {requestId} in {durationMs} ms", node, channel, message, requestId, durationMs); } }
public void ConnectionSucceeded(INetNode node, IPEndPoint address, INetChannel channel, int durationMs) { if (_logger.IsEnabled(LogEventLevel.Information)) { _logger.Information("NetNode {@node} has connected to {@address} with {@channel} in {durationMs} ms", node, address, channel, durationMs); } }
public void NetChannelRequestStarted(INetNode node, INetChannel channel, Message request, Guid requestId) { if (_logger.IsEnabled(LogEventLevel.Debug)) { _logger.Debug("NetNode {@node} on NetChannel {@channel} sending request {@message} with id {requestId}", node, channel, request, requestId); } }
public void NetChannelSentReplyMessage(INetNode node, INetChannel channel, Message reply, IOperationContext operation) { if (_logger.IsEnabled(LogEventLevel.Debug)) { _logger.Debug("NetNode {@node} on NetChannel {@channel} sent reply {@message} for operation {@operation}", node, channel, reply, operation); } }
private void HandleJoinPacket(object sender, PacketEventArgs e) { INetNode node = (INetNode)sender; if (e.Type == PacketType.Connect) { node.SendPacket(PacketType.Waiting, new byte [0]); } }
/// <summary> /// Creates a new directed NetEdge from the origin to the destination. /// </summary> /// <param name="origin">The node that the edge emits from.</param> /// <param name="destination">The node that the edge points to.</param> /// <param name="isBidirectional"> /// Returns true if there exists an edge pointing the opposite direction. /// </param> public NetEdge(INetNode origin, INetNode destination, bool isBidirectional) { origin.AssertNotNull(nameof(origin)); destination.AssertNotNull(nameof(destination)); this.origin = origin; this.destination = destination; this.isBidirectional = isBidirectional; }
/// <summary> /// Creates a new directed NetEdge from the origin to the destination. /// </summary> /// <param name="origin">The node that the edge emits from.</param> /// <param name="destination">The node that the edge points to.</param> /// <param name="isBidirectional"> /// Returns true if there exists an edge pointing the opposite direction. /// </param> public NetEdge(INetNode origin, INetNode destination, bool isBidirectional) { origin.AssertNotNull(nameof(origin)); destination.AssertNotNull(nameof(destination)); this.origin = origin; this.destination = destination; this.isBidirectional = isBidirectional; }
/// <summary> /// Creates a new NetGraph representation from raw data. /// </summary> /// <param name="nodes"> /// A list of all nodes. The first node is assumed to be this computer. /// </param> private NetGraph(IEnumerable <INetNode> nodes) { nodes.AssertNotNull(nameof(nodes)); if (nodes.FirstOrDefault() != null) { this.thisNode = nodes.First(); } this.nodes = nodes.ToImmutableDictionary(edge => edge.Guid, edge => edge); }
async static Task Run(INetNode node) { node.Start(); Console.WriteLine("Input server endpoint in form of ipaddress:port"); string[] addressAndPort = Console.ReadLine().Split(':'); var endpoint = new IPEndPoint(IPAddress.Parse(addressAndPort[0]), int.Parse(addressAndPort[1])); //before doing any network comms we should connect to some server node using (INetChannel channel = await node.Connect(endpoint)) { await Task.Yield(); Console.WriteLine("Enter your name"); string name = Console.ReadLine(); Console.WriteLine("Enter chat room name"); string roomName = Console.ReadLine(); //using connected channel we can send in request/reply pattern JoinRoomResponse response = await channel.SendRequestAsync <JoinRoomResponse>( new JoinRoom { ClientName = name, RoomName = roomName }); if (response.RetCode == JoinRoomRetCode.NameIsTaken) { Console.WriteLine("Name is taken"); return; } Console.WriteLine("You are connected, say something or enter exit"); bool exit = false; while (!exit) { await Task.Yield(); //client uses single threaded processing, so it's better noto block it with Console.Readline string text = Console.ReadLine(); if (text == "exit") { exit = true; } else { //or we can send just one way messages channel.Send(new Say { Text = text }); } } } }
/// <summary> /// Creates a new NetGraph representation from raw data. /// </summary> /// <param name="nodes"> /// A list of all nodes. The first node is assumed to be this computer. /// </param> private NetGraph(IEnumerable<INetNode> nodes) { nodes.AssertNotNull(nameof(nodes)); if (nodes.FirstOrDefault() != null) { this.thisNode = nodes.First(); } this.nodes = nodes.ToImmutableDictionary(edge => edge.Guid, edge => edge); }
NetChannel CreatePeer(INetNode node, ITransportChannel transport) { var peer = new AsyncProcessingNetChannel(builder => builder .UseFiber(_fiber) .UseConfigurableClientDispatcher((handlersBuilder) => { _messageHandlingConfigurator(handlersBuilder); return(handlersBuilder); }), node, transport, MessageSerializer, Logger, Config, _bufferPool); return(peer); }
async static Task Run(INetNode node) { node.Start(); Console.WriteLine("Input server endpoint in form of ipaddress:port"); string[] addressAndPort = Console.ReadLine().Split(':'); var endpoint = new IPEndPoint(IPAddress.Parse(addressAndPort[0]), int.Parse(addressAndPort[1])); //before doing any network comms we should connect to some server node using (INetChannel channel = await node.Connect(endpoint)) { await Task.Yield(); Console.WriteLine("Enter your name"); string name = Console.ReadLine(); Console.WriteLine("Enter chat room name"); string roomName = Console.ReadLine(); //using connected channel we can send in request/reply pattern JoinRoomResponse response = await channel.SendRequestAsync<JoinRoomResponse>( new JoinRoom { ClientName = name, RoomName = roomName }); if (response.RetCode == JoinRoomRetCode.NameIsTaken) { Console.WriteLine("Name is taken"); return; } Console.WriteLine("You are connected, say something or enter exit"); bool exit = false; while (!exit) { await Task.Yield(); //client uses single threaded processing, so it's better noto block it with Console.Readline string text = Console.ReadLine(); if (text == "exit") { exit = true; } else { //or we can send just one way messages channel.Send(new Say {Text = text}); } } } }
public AzureEventHubActorSystem(ushort id, string hubName, string hubConnectionString, string blobStorageConnectionString, bool shouldProcessEvents, Func <TActor> actorFactory, INetNodeConfig config, INetNode serverNode, IMessageSerializer serializer, IAzureEventHubActorSystemEvents logger, TimeSpan checkpointEveryTimespan) { _id = id; _hubConnectionString = hubConnectionString; _blobStorageConnectionString = blobStorageConnectionString; _shouldProcessEvents = shouldProcessEvents; _actorFactory = actorFactory; _config = config; _serverNode = serverNode; _serializer = serializer; _logger = logger; _checkpointEveryTimespan = checkpointEveryTimespan; _hubName = hubName; _consumerGroup = typeof(TActor).Name; }
private INetNode[] GetNetworkNodes() { var netNodes = new INetNode[_netMap.Count]; int index = 0; ActivationType actType = ActivationType.IDENTITY; foreach (var nodeMap in _netMap.Keys) { //var genomeNode = _genome.NodeList[nodeMap.NeuronId]; var genomeNode = _genome.NodeList.First(n => n.Idx == nodeMap.NeuronId); switch (genomeNode.ActivationType) { case NodeActivationType.NONE: actType = ActivationType.IDENTITY; break; case NodeActivationType.LEAKYRELU: actType = ActivationType.LEAKYRELU; break; case NodeActivationType.SIGMOID: actType = ActivationType.SIGMOID; break; default: throw new ArgumentOutOfRangeException(nameof(NodeActivationType), genomeNode.ActivationType, null); } if (genomeNode.NodeType == NodeGeneType.BIAS) { actType = ActivationType.BIAS; } netNodes[index] = new NetNode(actType); index++; } return(netNodes); }
public SFChatClientNetChannel(INetNode node, ITransportChannel transportChannel, IMessageSerializer serializer, ICoreEvents logger, INetNodeConfig config, IBufferPool bufferPool) : base(node, transportChannel, serializer, logger, config, bufferPool) { }
public NetCommunicationClientFactory(INetNode netNode, IServicePartitionResolver servicePartitionResolver = null, IEnumerable <IExceptionHandler> exceptionHandlers = null, string traceId = null) : base(servicePartitionResolver, AddExceptionHandler(exceptionHandlers), traceId) { _netNode = netNode; }
public void OperationProcessed(INetNode node, INetChannel channel, IOperationContext operation) { if (_logger.IsEnabled(LogEventLevel.Information)) _logger.Information("NetNode {@node} on NetChannel {@channel} processed {@operation}", node, channel, operation); }
public void ConnectionSucceeded(INetNode node, IPEndPoint address, INetChannel channel, int durationMs) { if (_logger.IsEnabled(LogEventLevel.Information)) _logger.Information("NetNode {@node} has connected to {@address} with {@channel} in {durationMs} ms", node, address, channel, durationMs); }
public void NetChannelRequestStarted(INetNode node, INetChannel channel, Message request, Guid requestId) { if (_logger.IsEnabled(LogEventLevel.Debug)) _logger.Debug("NetNode {@node} on NetChannel {@channel} sending request {@message} with id {requestId}", node, channel, request, requestId); }
public void NetChannelSentReplyMessage(INetNode node, INetChannel channel, Message reply, IOperationContext operation) { if (_logger.IsEnabled(LogEventLevel.Debug)) _logger.Debug("NetNode {@node} on NetChannel {@channel} sent reply {@message} for operation {@operation}", node, channel, reply, operation); }
public void CantReplyToOneWayMessage(INetNode node, IOperationContext operation) { if (_logger.IsEnabled(LogEventLevel.Debug)) _logger.Warning("NetChannel {@channel} is trying to reply to one way message {@message}", operation.ReplyChannel, operation.Message); }
public void OperationProcessingFailed(INetNode node, INetChannel channel, IOperationContext operation, Exception exception) { if (_logger.IsEnabled(LogEventLevel.Warning)) _logger.Warning("NetNode {@node} on NetChannel {@channel} failed to process operation {@operation} with {@exception}", node, channel, operation, exception); }
public void NetChannelRequestFailed(INetNode node, NetChannel channel, ErrorMessage error, Guid requestId, int durationMs) { if (_logger.IsEnabled(LogEventLevel.Warning)) _logger.Warning("NetNode {@node} NetChannel {@channel} sent request failed with {@error} for {requestId} in {durationMs} ms", node, channel, error, requestId, durationMs); }
public void ActorActivated(INetNode node, ActorKey actorKey) { if (_logger.IsEnabled(LogEventLevel.Information)) _logger.Information("actor:{@actorKey} is activated on node:{@node}", actorKey, node); }
public void NetChannelRequestTimedOut(INetNode node, INetChannel channel, Message message, Guid requestId, int durationMs) { if (_logger.IsEnabled(LogEventLevel.Warning)) _logger.Warning("NetChannel {@channel} has timed out within {durationMs} ms on sending request {@message} {requestId}", channel, durationMs, message, requestId); }
public void ConnectionHasTimedOut(INetNode node, IPEndPoint address) { if (_logger.IsEnabled(LogEventLevel.Warning)) _logger.Warning("NetNode {@node} has failed to connect to {@address} within alloted time", node, address); }
public ServiceFabricCommunicationListenerAdapter(INetNode netNode, string transportSchema = "net.tcp") { _netNode = netNode; _transportSchema = transportSchema; }
public void ConnectingTo(INetNode node, IPEndPoint address) { if (_logger.IsEnabled(LogEventLevel.Debug)) _logger.Debug("NetNode {@node} is trying to connect to {@address}", node, address); }
public SFChatClientNetChannel(INetNode node, ITransportChannel transportChannel, IMessageSerializer serializer, ICoreEvents logger, INetNodeConfig config, IBufferPool bufferPool) : base(node, transportChannel, serializer, logger, config, bufferPool) { }
public void NetChannelDisconnected(INetNode node, INetChannel channel) { if (_logger.IsEnabled(LogEventLevel.Debug)) _logger.Debug("NetNode {@node} NetChannel {@channel} has disconnected", node, channel); }
public void NetChannelIsDisposing(INetNode node, INetChannel channel) { if (_logger.IsEnabled(LogEventLevel.Debug)) _logger.Debug("NetChannel {@channel} is closing", channel); }
public void NodeUpdateLoopError(INetNode node, Exception exception) { if (_logger.IsEnabled(LogEventLevel.Error)) _logger.Error("NetNode {@node} unexpected exception {@exception}", node, exception); }
public void NetChannelRequestCompleted(INetNode node, INetChannel channel, Message message, Guid requestId, int durationMs) { if (_logger.IsEnabled(LogEventLevel.Information)) _logger.Information("NetNode {@node} NetChannel {@channel} is received reply {@message} for {requestId} in {durationMs} ms", node, channel, message, requestId, durationMs); }
public void NodeStopped(INetNode node) { if (_logger.IsEnabled(LogEventLevel.Warning)) _logger.Warning("NetNode {@node} has stopped", node); }
public MouseActorsBackendClientNetChannel(IActorSystem<ITestActor> actorSystem, INetNode node, ITransportChannel transportChannel, IMessageSerializer serializer, ICoreEvents logger, INetNodeConfig config, IBufferPool bufferPool) : base(node, transportChannel, serializer, logger, config, bufferPool) { _actorSystem = actorSystem; }
public void NodeUpdateLoopStarted(INetNode node) { if (_logger.IsEnabled(LogEventLevel.Information)) _logger.Information("Update loop of NetNode {@node} has started", node); }
public void NetChannelSentMessage(INetNode node, INetChannel channel, Message message) { if (_logger.IsEnabled(LogEventLevel.Debug)) _logger.Debug("NetChannel {@channel} has sent message {@message}", channel, message); }
public ServiceFabricCommunicationListenerAdapter(INetNode netNode, string transportSchema = "net.tcp") { _netNode = netNode; _transportSchema = transportSchema; }