internal void DistributeRemoveTo(AttributeSet set, IEnumerable <Node> nodes) { // remove attributes first, then the set var allNodes = nodes as Node[] ?? nodes.ToArray(); foreach (var untracked in set.All) { DistributeTo(set, untracked, ApplicationMessageType.RemoveAttribute, allNodes); } var removeSet = new RemoveAttributeSet(_node, set); var confirmable = _confirmables.UnconfirmedFor(removeSet, allNodes); _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, removeSet.ToPayload()), confirmable.UnconfirmedNodes); _application.InformAttributeSetRemoved(set.Name); }
public void TestInboundStreamInterestRemoveAttributeSet() { var inboundStreamInterest = TestWorld.ActorFor <IInboundStreamInterest>( () => new AttributesAgentActor(_localNode, Application, _outboundStream.Actor, Config, _interest)); var createMessage = CreateAttributeSet.From(_localNode, _set); inboundStreamInterest.Actor.HandleInboundStreamMessage(AddressType.Op, RawMessageFor(_localNodeId, _localNode.Name, createMessage)); var removeMessage = RemoveAttributeSet.From(_localNode, _set); inboundStreamInterest.Actor.HandleInboundStreamMessage(AddressType.Op, RawMessageFor(_localNodeId, _localNode.Name, removeMessage)); var channel1 = _channelProvider.ChannelFor(_localNodeId); Assert.Equal(2, Mock(channel1).Writes.Count); Assert.Equal(1, Application.InformAttributeSetCreatedCheck.Get()); Assert.Equal(1, Application.InformAttributeSetRemovedCheck.Get()); }
internal void DistributeTo( AttributeSet set, TrackedAttribute tracked, ApplicationMessageType type, IEnumerable <Node> nodes) { switch (type) { case ApplicationMessageType.AddAttribute: var add = AddAttribute.From(_node, set, tracked); var addConfirmable = _confirmables.UnconfirmedFor(add, nodes); _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, add.ToPayload()), addConfirmable.UnconfirmedNodes); _application.InformAttributeAdded(set.Name !, tracked.Attribute?.Name); break; case ApplicationMessageType.RemoveAttribute: var remove = RemoveAttribute.From(_node, set, tracked); var removeConfirmable = _confirmables.UnconfirmedFor(remove, nodes); _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, remove.ToPayload()), removeConfirmable.UnconfirmedNodes); _application.InformAttributeRemoved(set.Name !, tracked.Attribute?.Name); break; case ApplicationMessageType.RemoveAttributeSet: var removeSet = RemoveAttributeSet.From(_node, set); var removeSetConfirmable = _confirmables.UnconfirmedFor(removeSet, nodes); _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, removeSet.ToPayload()), removeSetConfirmable.UnconfirmedNodes); _application.InformAttributeSetRemoved(set.Name); break; case ApplicationMessageType.ReplaceAttribute: var replace = ReplaceAttribute.From(_node, set, tracked); var replaceConfirmable = _confirmables.UnconfirmedFor(replace, nodes); _outbound.Application(ApplicationSays.From(_node.Id, _node.Name, replace.ToPayload()), replaceConfirmable.UnconfirmedNodes); _application.InformAttributeReplaced(set.Name !, tracked.Attribute?.Name); break; default: throw new InvalidOperationException("Cannot distribute unknown ApplicationMessageType."); } }