akkadotnet/akka.net — pull request #369 by Aaronontheweb (2014-09-04 01:35:33+00:00)
Title: Akka cluster checkin

Synchronizing some changes on the Akka.Cluster branch - I've been keeping everything regularly in-sync with dev but I figure it's time to share some of the work that's been done.

## Completed thus far

1. #303 and #304 are finished and covered with unit tests.
1. The `Cluster` ActorSystem extension itself is complete.
1. All of the `Gossip` and `MetricsGossip` plumbing, message types, and built-in actors have been completed. Covered with tests.
1. Metrics collection has been implemented using performance counters; covered with tests.
1. All of the `ClusterSettings` have been implemented, covered with tests.

## Working on
1. @smalldave ported a giant chunk of the `ClusterDaemon` over, but there's still a lot of work to do there.
1. None of the cluster `FailureDetection` and `Heartbeat` stuff have been implemented yet
1. None of the cluster-specific routers have been implemented yet, and let's be honest: that's the cool stuff.
1. `AutoDown` has not been implemented yet.
1. None of the Multi-JVM tests have been ported yet.
1. `ClusterActorRefProvider` requires some work, but that's dependent on `ClusterDaemon`.

## Stuff worth reviewing now
1. Scala has a convenient `Number` base class for all numeric types. C# doesn't have anything as nice as that. As a result, I decided to standardize all of our metrics collection on `double` types rather than do all of the crazy numeric conversion stuff that canonical Akka does. Going to add some line comments where relevant.
1. Inside the Metrics collector, there's a lot of Mono support stuff I am not sure about. CC @mattnischan. We added a reference to `Microsoft.VisualBasic` in order to get access to the `ComputerInfo.TotalMemory` metric, which is really just window dressing around a low-level `SystemInfoEx` (I think) P/Invoke call. We also use a couple of performance counters to get system available memory and CPU utilization. I have no about how Mono-compatible any of this code is, and I'm open to changing it before it gets released. For the time being I just needed something to get me started so I can work on `ClusterDaemon` and routing. See https://github.com/Aaronontheweb/akka.net/blob/a92a49df2f2e5eff4e8af526a2502d9cc5849c50/src/core/Akka.Cluster/ClusterMetricsCollector.cs
1. `Microsoft.Bcl.Immutable` is more or less an intractable part of Akka.Cluster in this design. Akka.Cluster doesn't do any networking or anything else - it's 80% state management and 20% state propagation to peers, and the `ImmutableHashSet` + `ImmutableSortedSet` make it much easier to handle gossip, vector clock, and node ring updates. The collections in Akka.Cluster actually do need to be immutable in most cases, since everything in the gossip protocol depends heavily on versioning. If we drop the Microsoft.Bcl.Immutable dependency we'll have to implement something like it ourselves, so it's worth considering the tradeoffs now.