Akka.Cluster Commands
The Akka.Cluster commands supported by Petabridge.Cmd.Host can be added to your Petabridge.Cmd.Host installation by installing the Petabridge.Cmd.Cluster NuGet package:
PM> Install-Package Petabridge.Cmd.Cluster
And then inside your Akka.NET application, you can simply register the ClusterCommands command palette with your ActorSystem using the following syntax:
using Akka.Actor;
using Petabridge.Cmd.Cluster;
namespace Petabridge.Cmd.Host.Cluster.Sample
{
    public class Program
    {
        private static void Main(string[] args)
        {
            using (var a = ActorSystem.Create("webcrawler"))
            {
                var cmd = PetabridgeCmd.Get(a);
                cmd.RegisterCommandPalette(ClusterCommands.Instance);
                cmd.Start();
                a.WhenTerminated.Wait();
            }
        }
    }
}
Available Commands
| Command Name | Description | 
|---|---|
| `cluster join` | Has the current node JOIN one or more nodes at the specified address. | 
| `cluster leave` | Has the specified node LEAVE the cluster if it is currently a member. | 
| `cluster down` | Has the current node DOWN one or more nodes at the specified address(es). | 
| `cluster down-unreachable` | Has the current node DOWN all nodes that are currently UNREACHABLE. | 
| `cluster status` | Gets the cluster status of the current node. | 
| `cluster show` | Describes the current state of the cluster from the perspective of the current node. | 
| `cluster leader` | Returns the `Address` of the current leader in the cluster. Useful for debugging purposes. | 
| `cluster tail` | Similar to [the `log tail` command](logging-commands.md), `cluster tail` writes all of the cluster membership, reachability, and leader change events out to the console until stopped via Control + C. | 
cluster join
cluster join is only intended to be used for nodes that haven't already joined an Akka.NET Cluster.
If the current node (the one the pbm client is connected to) is already a member of a cluster then cluster join will fail.
cluster join takes the following arguments:
| Argument Name | Switches | Mandatory? | Allow Multiple? | Is Flag? | Description | 
|---|---|---|---|---|---|
| address | -a or -A | yes | yes | no | The Akka.NET address of the node we're going to attempt to join. Should be in the form of 'akka[scheme]://[actor system name]@[host]:[port]', i.e. 'akka.tcp://[email protected]:9001' | 
Examples
Joining an available node.
pbm [host:port] cluster join -a akka.tcp://[email protected]:9009
cluster leave
cluster leave takes a single optional argument: the address of the node we wish to have leave the cluster.
| Argument Name | Switches | Mandatory? | Allow Multiple? | Is Flag? | Description | 
|---|---|---|---|---|---|
| address | -a or -A | no | no | no | The Akka.NET address of the node attempting to leave the cluster. If left blank, the current node will leave. Should be in the form of 'akka[scheme]://[actor system name]@[host]:[port]', i.e. 'akka.tcp://[email protected]:9001' | 
If the specified node is not already a member of an Akka.NET Cluster, the cluster leave command will fail with an error message.
Examples
Current node leaves the cluster:
pbm [host:port] cluster leave
Other node gracefully leaves the cluster:
pbm [host:port] cluster leave -a akka.tcp://[email protected]:4053
cluster down
cluster down is a useful tool in scenarios where a node in your cluster have become unreachable and it needs to be manually downed so the cluster can achieve convergence again and begin marking new members as up.
cluster down takes the following arguments:
| Argument Name | Switches | Mandatory? | Allow Multiple? | Is Flag? | Description | 
|---|---|---|---|---|---|
| address | -a or -A | yes | yes | no | The Akka.NET address of the node we're going to attempt to down. Should be in the form of 'akka[scheme]://[actor system name]@[host]:[port]', i.e. 'akka.tcp://[email protected]:9001' | 
Examples
Downing two unreachable nodes in a cluster via their addresses.
pbm [host:port] cluster down -a akka.tcp://[email protected]:9000 -a akka.tcp://[email protected]:9000
cluster down-unreachable
cluster down-unreachable is special version of the cluster down command that doesn't require the end-user to specify any node addresses. Instead, the currently connected node will automatically down all nodes in the cluster who currently have a status of UNREACHABLE. If there are no unreachable nodes at the time this command is issued, it simply behaves as a no-op.
Examples
Downing two unreachable nodes in a cluster.
pbm [host:port] cluster down-unreachable
cluster show
cluster show can be used to help visualize the current state of the cluster. It will provide the pbm client with the list of all other members of the same cluster as the Petabridge.Cmd.Host and will also include data such as each node's roles, reachability, and address.
| Argument Name | Switches | Mandatory? | Allow Multiple? | Is Flag? | Description | 
|---|---|---|---|---|---|
| role | -r or -R | no | yes | no | Shows only nodes with 1 or more specified role names | 
| status | -s or -S | no | yes | no | SShows only nodes with 1 or more specified member statuses. Valid values are [up, exiting, leaving, joining]. | 
| unreachable | u or -U | no | yes | yes | Show only nodes that are UNREACHABLE. | 
| reachable | -a or -A | no | yes | yes | Show only nodes that are REACHABLE. | 
Examples
Show all nodes in the cluster regardless of status, role, or reachability.
pbm [host:port] cluster show
Show all nodes in the cluster that are unreachable.
pbm [host:port] cluster show -U
Show all nodes in the cluster in role "web" that are unreachable.
pbm [host:port] cluster show -U -r "web"
cluster status
cluster status is a lightweight version of cluster show that shows just the status of the current node the pbm client is connected to. cluster status takes no arguments.
cluster leader
cluster leader will just return the Address of the node who is currently the leader of the cluster. It takes no arguments.
cluster tail
cluster tail will print all of the cluster membership, reachability, and leadership change events out to the console until explicitly interrupted via Control + C.