public Disconnect(RoleName node, RoleName target, bool abort) { _node = node; _target = target; _abort = abort; }
public NodeInfo(RoleName name, Address addr, IActorRef fsm) { _name = name; _addr = addr; _fsm = fsm; }
public Remove(RoleName node) { _node = node; }
protected void InitFSM() { StartWith(State.Initial, null); WhenUnhandled(@event => { var clientDisconnected = @event.FsmEvent as Controller.ClientDisconnected; if (clientDisconnected != null) { if (@event.StateData != null) { @event.StateData.Tell(new Failure(new Controller.ClientDisconnectedException("client disconnected in state " + StateName + ": " + _channel))); } return(Stop()); } return(null); }); OnTermination(@event => { _controller.Tell(new Controller.ClientDisconnected(_roleName)); _channel.Close(); }); When(State.Initial, @event => { var hello = @event.FsmEvent as Hello; if (hello != null) { _roleName = new RoleName(hello.Name); _controller.Tell(new Controller.NodeInfo(_roleName, hello.Address, Self)); return(GoTo(State.Ready)); } if (@event.FsmEvent is INetworkOp) { _log.Warning("client {0}, sent not Hello in first message (instead {1}), disconnecting", _channel.RemoteHost.ToEndPoint(), @event.FsmEvent); _channel.Close(); return(Stop()); } if (@event.FsmEvent is IToClient) { _log.Warning("cannot send {0} in state Initial", @event.FsmEvent); return(Stay()); } if (@event.FsmEvent is StateTimeout) { _log.Info("closing channel to {0} because of Hello timeout", _channel.RemoteHost.ToEndPoint()); _channel.Close(); return(Stop()); } return(null); }, TimeSpan.FromSeconds(10)); When(State.Ready, @event => { if (@event.FsmEvent is Done && @event.StateData != null) { @event.StateData.Tell(@event.FsmEvent); return(Stay().Using(null)); } if (@event.FsmEvent is IServerOp) { _controller.Tell(@event.FsmEvent); return(Stay()); } if (@event.FsmEvent is INetworkOp) { _log.Warning("client {0} sent unsupported message {1}", _channel.RemoteHost.ToEndPoint(), @event.FsmEvent); return(Stop()); } var toClient = @event.FsmEvent as IToClient; if (toClient != null) { if (toClient.Msg is IUnconfirmedClientOp) { _channel.Write(toClient.Msg); return(Stay()); } if (@event.StateData == null) { _channel.Write(toClient.Msg); return(Stay().Using(Sender)); } _log.Warning("cannot send {0} while waiting for previous ACK", toClient.Msg); return(Stay()); } return(null); }); Initialize(); }
public ClientLostException(Data barrierData, RoleName client) : base(string.Format("unannounced disconnect of {0}", client)) { Client = client; BarrierData = barrierData; }
/// <summary> /// Switch the helios pipeline of the remote support into blackhole mode for /// sending and/or receiving: it will just drop all messages right before /// submitting them to the Socket or right after receiving them from the /// Socket. /// /// ====Note==== /// To use this feature you must activate the failure injector and throttler /// transport adapters by specifying `testTransport(on = true)` in your MultiNodeConfig. /// </summary> /// <param name="node">is the symbolic name of the node which is to be affected</param> /// <param name="target">is the symbolic name of the other node to which connectivity shall be impeded</param> /// <param name="direction">can be either `Direction.Send`, `Direction.Receive` or `Direction.Both`</param> /// <returns></returns> public Task <Done> Blackhole(RoleName node, RoleName target, ThrottleTransportAdapter.Direction direction) { return(Throttle(node, target, direction, 0f)); }
/// <summary> /// Tell the remote support to TCP_RESET the connection to the given remote /// peer. It works regardless of whether the recipient was initiator or /// responder. /// </summary> /// <param name="node">is the symbolic name of the node which is to be affected</param> /// <param name="target">is the symbolic name of the other node to which connectivity shall be impeded</param> /// <returns></returns> public Task <Done> Abort(RoleName node, RoleName target) { return(Controller.Ask <Done>(new Disconnect(node, target, true), Settings.QueryTimeout)); }
public Replacement(string tag, RoleName role, MultiNodeSpec spec) { _tag = tag; _role = role; _addr = new Lazy <string>(() => spec.Node(role).Address.ToString()); }
public void DeployOn(RoleName role, string deployment) { _deployments.TryGetValue(role, out var roleDeployments); _deployments = _deployments.SetItem(role, roleDeployments == null ? ImmutableList.Create(deployment) : roleDeployments.Add(deployment)); }
internal ImmutableList <string> Deployments(RoleName node) { _deployments.TryGetValue(node, out var deployments); return(deployments == null ? _allDeploy : deployments.AddRange(_allDeploy)); }
/// <summary> /// Query the controller for the transport address of the given node (by role name) and /// return that as an ActorPath for easy composition: /// /// <code>var serviceA = Sys.ActorSelection(Node(new RoleName("master")) / "user" / "serviceA");</code> /// </summary> public ActorPath Node(RoleName role) { //TODO: Async stuff here return(new RootActorPath(TestConductor.GetAddressFor(role).Result)); }
public ClientDisconnected(RoleName name) { _name = name; }
public NodeInfo(RoleName name, Address addr, IActorRef fsm) { Name = name; Addr = addr; FSM = fsm; }
public ClientLostException(Data barrierData, RoleName client) : base($"unannounced disconnect of {client}") { Client = client; BarrierData = barrierData; }
public Terminate(RoleName node, Either <bool, int> shutdownOrExit) { _node = node; _shutdownOrExit = shutdownOrExit; }
bool Equals(RoleName other) { return(string.Equals(_name, other._name)); }
/// <summary> /// Make the remoting pipeline on the node throttle data sent to or received /// from the given remote peer. Throttling works by delaying packet submission /// within the netty pipeline until the packet would have been completely sent /// according to the given rate, the previous packet completion and the current /// packet length. In case of large packets they are split up if the calculated /// end pause would exceed `akka.testconductor.packet-split-threshold` /// (roughly). All of this uses the system’s scheduler, which is not /// terribly precise and will execute tasks later than they are schedule (even /// on average), but that is countered by using the actual execution time for /// determining how much to send, leading to the correct output rate, but with /// increased latency. /// /// ====Note==== /// To use this feature you must activate the failure injector and throttler /// transport adapters by specifying `testTransport(on = true)` in your MultiNodeConfig. /// </summary> /// <param name="node">is the symbolic name of the node which is to be affected</param> /// <param name="target">is the symbolic name of the other node to which connectivity shall be throttled</param> /// <param name="direction">can be either `Direction.Send`, `Direction.Receive` or `Direction.Both`</param> /// <param name="rateMBit">is the maximum data rate in MBit</param> /// <returns></returns> public Task <Done> Throttle(RoleName node, RoleName target, ThrottleTransportAdapter.Direction direction, float rateMBit) { RequireTestConductorTransport(); return(Controller.Ask <Done>(new Throttle(node, target, direction, rateMBit), Settings.QueryTimeout)); }
/// <summary> /// Tell the remote support to TCP_RESET the connection to the given remote /// peer. It works regardless of whether the recipient was initiator or /// responder. /// </summary> /// <param name="node">is the symbolic name of the node which is to be affected</param> /// <param name="target">is the symbolic name of the other node to which connectivity shall be impeded</param> /// <returns></returns> public Task <Done> Abort(RoleName node, RoleName target) { return(Controller.Ask <Done>(new Disconnect(node, target, true))); }
/// <summary> /// Switch the Helios pipeline of the remote support into pass through mode for /// sending and/or receiving. /// /// ====Note==== /// To use this feature you must activate the failure injector and throttler /// transport adapters by specifying `testTransport(on = true)` in your MultiNodeConfig. /// </summary> /// <param name="node">is the symbolic name of the node which is to be affected</param> /// <param name="target">is the symbolic name of the other node to which connectivity shall be impeded</param> /// <param name="direction">can be either `Direction.Send`, `Direction.Receive` or `Direction.Both`</param> /// <returns></returns> public Task <Done> PassThrough(RoleName node, RoleName target, ThrottleTransportAdapter.Direction direction) { return(Throttle(node, target, direction, -1f)); }
/// <summary> /// Remove a remote host from the list, so that the remaining nodes may still /// pass subsequent barriers. This must be done before the client connection /// breaks down in order to affect an “orderly” removal (i.e. without failing /// present and future barriers). /// </summary> /// <param name="node">is the symbolic name of the node which is to be removed</param> /// <returns></returns> public Task <Done> RemoveNode(RoleName node) { return(Controller.Ask <Done>(new Remove(node))); }
/// <summary> /// Remove a remote host from the list, so that the remaining nodes may still /// pass subsequent barriers. This must be done before the client connection /// breaks down in order to affect an “orderly” removal (i.e. without failing /// present and future barriers). /// </summary> /// <param name="node">is the symbolic name of the node which is to be removed</param> /// <returns></returns> public Task <Done> RemoveNode(RoleName node) { return(Controller.Ask <Done>(new Remove(node), Settings.QueryTimeout)); }
public GetAddress(RoleName node) { _node = node; }
public Task <Address> GetAddressFor(RoleName name) { return(_client.Ask <Address>(new ToServer <GetAddress>(new GetAddress(name)), Settings.QueryTimeout)); }
public AddressReply(RoleName node, Address addr) { _node = node; _addr = addr; }
public RemoveClient(RoleName name) { Name = name; }
public Task <Address> GetAddressFor(RoleName name) { //TODO: QueryTimeout implicit? return(_client.Ask <Address>(new ToServer <GetAddress>(new GetAddress(name)))); }