本文整理汇总了C#中UniqueAddress类的典型用法代码示例。如果您正苦于以下问题:C# UniqueAddress类的具体用法?C# UniqueAddress怎么用?C# UniqueAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UniqueAddress类属于命名空间,在下文中一共展示了UniqueAddress类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Record
public Record(UniqueAddress observer, UniqueAddress subject, ReachabilityStatus status, long version)
{
_observer = observer;
_subject = subject;
_status = status;
_version = version;
}
示例2: EchoConsumerActor
public EchoConsumerActor(ClusterNodeContext context)
{
_clusterContext = context;
_clusterUniqueAddress = Cluster.Get(Context.System).SelfUniqueAddress;
Receive<string>(m => OnMessage(m));
}
示例3: Fd
private FailureDetectorStub Fd(ClusterHeartbeatSenderState state, UniqueAddress node)
{
return
state.FailureDetector.AsInstanceOf<DefaultFailureDetectorRegistry<Address>>()
.GetFailureDetector(node.Address)
.AsInstanceOf<FailureDetectorStub>();
}
示例4: MemberCreate
/// <summary>
/// Creates a member from internal Akka method
/// </summary>
/// <returns>The new member</returns>
public static Member MemberCreate(UniqueAddress uniqueAddress, int upNumber, MemberStatus status, ImmutableHashSet<string> roles)
{
var createMethod =
typeof(Member).GetMethods(BindingFlags.NonPublic | BindingFlags.Static)
.First(m => m.Name == "Create" && m.GetParameters().Length == 4);
return (Member)createMethod.Invoke(null, new object[] { uniqueAddress, upNumber, status, roles });
}
示例5: ClusterMessages_must_be_serializable
public void ClusterMessages_must_be_serializable()
{
var address = new Address("akka.tcp", "system", "some.host.org", 4711);
var uniqueAddress = new UniqueAddress(address, 17);
var address2 = new Address("akka.tcp", "system", "other.host.org", 4711);
var uniqueAddress2 = new UniqueAddress(address2, 18);
CheckSerialization(new InternalClusterAction.Join(uniqueAddress, ImmutableHashSet.Create("foo","bar")));
CheckSerialization(new ClusterUserAction.Leave(address));
CheckSerialization(new ClusterUserAction.Down(address));
CheckSerialization(new InternalClusterAction.InitJoin());
CheckSerialization(new InternalClusterAction.InitJoinAck(address));
CheckSerialization(new InternalClusterAction.InitJoinNack(address));
CheckSerialization(new ClusterHeartbeatSender.Heartbeat(address));
CheckSerialization(new ClusterHeartbeatSender.HeartbeatRsp(uniqueAddress));
var node1 = new VectorClock.Node("node1");
var node2 = new VectorClock.Node("node2");
var node3 = new VectorClock.Node("node3");
var node4 = new VectorClock.Node("node4");
var g1 =
new Gossip(ImmutableSortedSet.Create(a1, b1, c1, d1)).Increment(node1)
.Increment(node2)
.Seen(a1.UniqueAddress)
.Seen(b1.UniqueAddress);
var g2 = g1.Increment(node3).Increment(node4).Seen(a1.UniqueAddress).Seen(c1.UniqueAddress);
var reachability3 =
Reachability.Empty.Unreachable(a1.UniqueAddress, e1.UniqueAddress)
.Unreachable(b1.UniqueAddress, e1.UniqueAddress);
var g3 = g2.Copy(members: ImmutableSortedSet.Create(a1, b1, c1, d1, e1),
overview: g2.Overview.Copy(reachability: reachability3));
CheckSerialization(new GossipEnvelope(a1.UniqueAddress, uniqueAddress2, g1));
CheckSerialization(new GossipEnvelope(a1.UniqueAddress, uniqueAddress2, g2));
CheckSerialization(new GossipEnvelope(a1.UniqueAddress, uniqueAddress2, g3));
CheckSerialization(new GossipStatus(a1.UniqueAddress, g1.Version));
CheckSerialization(new GossipStatus(a1.UniqueAddress, g2.Version));
CheckSerialization(new GossipStatus(a1.UniqueAddress, g3.Version));
CheckSerialization(new InternalClusterAction.Welcome(uniqueAddress, g2));
var mg = new MetricsGossip(ImmutableHashSet.Create<NodeMetrics>(new[]
{
new NodeMetrics(a1.Address, 4711, ImmutableHashSet.Create<Metric>(new Metric("foo", 1.2, null))),
new NodeMetrics(b1.Address, 4712,
ImmutableHashSet.Create<Metric>(new Metric("foo", 2.1, new EWMA(100.0, 0.18))
, new Metric("bar1", Double.MinValue, null), new Metric("bar2", float.MaxValue, null),
new Metric("bar3", int.MaxValue, null), new Metric("bar4", long.MaxValue, null),
new Metric("bar5", double.MaxValue, null)))
}));
CheckSerialization(new MetricsGossipEnvelope(a1.Address, mg, true));
}
示例6: ClusterMessages_must_be_serializable
public void ClusterMessages_must_be_serializable()
{
var address = new Address("akka.tcp", "system", "some.host.org", 4711);
var uniqueAddress = new UniqueAddress(address, 17);
var address2 = new Address("akka.tcp", "system", "other.host.org", 4711);
var uniqueAddress2 = new UniqueAddress(address2, 18);
CheckSerialization(new InternalClusterAction.Join(uniqueAddress, ImmutableHashSet.Create("foo","bar")));
CheckSerialization(new ClusterUserAction.Leave(address));
CheckSerialization(new ClusterUserAction.Down(address));
CheckSerialization(new InternalClusterAction.InitJoin());
CheckSerialization(new InternalClusterAction.InitJoinAck(address));
CheckSerialization(new InternalClusterAction.InitJoinNack(address));
CheckSerialization(new ClusterHeartbeatSender.Heartbeat(address));
CheckSerialization(new ClusterHeartbeatSender.HeartbeatRsp(uniqueAddress));
var node1 = new VectorClock.Node("node1");
var node2 = new VectorClock.Node("node2");
var node3 = new VectorClock.Node("node3");
var node4 = new VectorClock.Node("node4");
var g1 =
new Gossip(ImmutableSortedSet.Create(a1, b1, c1, d1)).Increment(node1)
.Increment(node2)
.Seen(a1.UniqueAddress)
.Seen(b1.UniqueAddress);
var g2 = g1.Increment(node3).Increment(node4).Seen(a1.UniqueAddress).Seen(c1.UniqueAddress);
var reachability3 =
Reachability.Empty.Unreachable(a1.UniqueAddress, e1.UniqueAddress)
.Unreachable(b1.UniqueAddress, e1.UniqueAddress);
var g3 = g2.Copy(members: ImmutableSortedSet.Create(a1, b1, c1, d1, e1),
overview: g2.Overview.Copy(reachability: reachability3));
CheckSerialization(new GossipEnvelope(a1.UniqueAddress, uniqueAddress2, g1));
CheckSerialization(new GossipEnvelope(a1.UniqueAddress, uniqueAddress2, g2));
CheckSerialization(new GossipEnvelope(a1.UniqueAddress, uniqueAddress2, g3));
CheckSerialization(new GossipStatus(a1.UniqueAddress, g1.Version));
CheckSerialization(new GossipStatus(a1.UniqueAddress, g2.Version));
CheckSerialization(new GossipStatus(a1.UniqueAddress, g3.Version));
CheckSerialization(new InternalClusterAction.Welcome(uniqueAddress, g2));
}
示例7: NextVersion
long NextVersion(UniqueAddress observer)
{
return CurrentVersion(observer) + 1;
}
示例8: Terminated
public Reachability Terminated(UniqueAddress observer, UniqueAddress subject)
{
return Change(observer, subject, ReachabilityStatus.Terminated);
}
示例9: CurrentVersion
long CurrentVersion(UniqueAddress observer)
{
long version;
return _versions.TryGetValue(observer, out version) ? version : 0;
}
示例10: RecordsFrom
public ImmutableList<Record> RecordsFrom(UniqueAddress observer)
{
var rows = ObserverRows(observer);
if (rows == null) return ImmutableList.Create<Record>();
return rows.Values.ToImmutableList();
}
示例11: Status
public ReachabilityStatus Status(UniqueAddress node)
{
if (_cache.Value.AllTerminated.Contains(node)) return ReachabilityStatus.Terminated;
if (_cache.Value.AllUnreachable.Contains(node)) return ReachabilityStatus.Unreachable;
return ReachabilityStatus.Reachable;
}
示例12: IsReachable
public bool IsReachable(UniqueAddress observer, UniqueAddress subject)
{
return Status(observer, subject) == ReachabilityStatus.Reachable;
}
示例13: Change
private Reachability Change(UniqueAddress observer, UniqueAddress subject, ReachabilityStatus status)
{
var v = NextVersion(observer);
var newVersions = _versions.SetItem(observer, v);
var newRecord = new Record(observer, subject, status, v);
var oldObserverRows = ObserverRows(observer);
if (oldObserverRows == null && status == ReachabilityStatus.Reachable) return this;
if (oldObserverRows == null) return new Reachability(_records.Add(newRecord), newVersions);
Record oldRecord = null;
oldObserverRows.TryGetValue(subject, out oldRecord);
if (oldRecord == null)
{
if (status == ReachabilityStatus.Reachable &&
oldObserverRows.Values.All(r => r.Status == ReachabilityStatus.Reachable))
{
return new Reachability(_records.FindAll(r => !r.Observer.Equals(observer)), newVersions);
}
return new Reachability(_records.Add(newRecord), newVersions);
}
if (oldRecord.Status == ReachabilityStatus.Terminated || oldRecord.Status == status)
return this;
if(status == ReachabilityStatus.Reachable &&
oldObserverRows.Values.All(r => r.Status == ReachabilityStatus.Reachable || r.Subject.Equals(subject)))
return new Reachability(_records.FindAll(r => !r.Observer.Equals(observer)), newVersions);
var newRecords = _records.SetItem(_records.IndexOf(oldRecord), newRecord);
return new Reachability(newRecords, newVersions);
}
示例14: ObserverRows
ImmutableDictionary<UniqueAddress, Record> ObserverRows(UniqueAddress observer)
{
ImmutableDictionary<UniqueAddress, Record> observerRows = null;
_cache.Value.ObserverRowMap.TryGetValue(observer, out observerRows);
return observerRows;
}
示例15: AllUnreachableFrom
public ImmutableHashSet<UniqueAddress> AllUnreachableFrom(UniqueAddress observer)
{
var observerRows = ObserverRows(observer);
if (observerRows == null) return ImmutableHashSet.Create<UniqueAddress>();
return
ImmutableHashSet.CreateRange(
observerRows.Where(p => p.Value.Status == ReachabilityStatus.Unreachable).Select(p => p.Key));
}