this repo has no description
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove init code from Hobbes

garrison 6d9a9a6e a376c75f

-103
-103
lib/hobbes.ex
··· 1 1 defmodule Hobbes do 2 - alias Hobbes.{ClusterConfig, ClusterNode} 3 2 alias Hobbes.Servers.{Coordinator, Manager} 4 3 alias Hobbes.Structs.Cluster 5 - 6 - alias Trinity.Sim 7 - 8 - defmodule AppShim do 9 - use Application 10 - 11 - alias Hobbes.Construct.SimSupervisor 12 - 13 - def start(_type, [config]) do 14 - children = [ 15 - {Hobbes.ClusterNode, config} 16 - ] 17 - SimSupervisor.start_link(children, max_restarts: 0) 18 - end 19 - end 20 - 21 - # Sim-only, relies on simulated nodes 22 - defp init_distributed_cluster(num_coordinators, %ClusterConfig{} = cluster_config) do 23 - coordinators = 24 - Enum.map(0..(num_coordinators - 1), fn i -> 25 - { 26 - String.to_atom("coordinator-#{i}"), 27 - String.to_atom("node#{i}"), 28 - } 29 - end) 30 - 31 - coordinators 32 - |> Enum.with_index() 33 - |> Enum.each(fn {{_name, node}, i} -> 34 - node_config = [ 35 - cluster: "cluster", 36 - coordinators: coordinators, 37 - coordinator_id: i, 38 - initial_cluster_config: cluster_config, 39 - 40 - slots: [ 41 - stateless: 6, 42 - tlog: [ 43 - "/tlog_1", 44 - ], 45 - storage: 1..4 |> Enum.map(&"/storage_#{&1}"), 46 - ], 47 - ] 48 - 49 - mfa = { 50 - Hobbes.AppShim, 51 - :start, 52 - [nil, [node_config]], 53 - } 54 - Sim.create_node(node, mfa) 55 - Sim.start_node(node) 56 - end) 57 - 58 - coordinators 59 - end 60 - 61 - defp init_local_cluster(num_coordinators, %ClusterConfig{} = cluster_config) do 62 - coordinators = 63 - Enum.map(0..(num_coordinators - 1), fn i -> 64 - String.to_atom("coordinator-#{i}") 65 - end) 66 - 67 - coordinators 68 - |> Enum.with_index() 69 - |> Enum.each(fn {_name, i} -> 70 - config = [ 71 - cluster: "cluster", 72 - coordinators: coordinators, 73 - coordinator_id: i, 74 - initial_cluster_config: cluster_config, 75 - 76 - slots: [ 77 - stateless: 6, 78 - tlog: [ 79 - "/tlog_1", 80 - ], 81 - storage: 1..4 |> Enum.map(&"/storage_#{&1}"), 82 - ], 83 - ] 84 - 85 - ClusterNode.start_link(config) 86 - end) 87 - 88 - coordinators 89 - end 90 - 91 - @spec start_cluster(Keyword.t) :: {:ok, [pid]} 92 - def start_cluster(opts) do 93 - num_coordinators = Keyword.get(opts, :num_coordinators, 3) 94 - config = ClusterConfig.from_opts(opts) 95 - 96 - coordinators = 97 - case Sim.simulated?() do 98 - true -> init_distributed_cluster(num_coordinators, config) 99 - false -> init_local_cluster(num_coordinators, config) 100 - end 101 - 102 - { 103 - :ok, 104 - coordinators, 105 - } 106 - end 107 4 108 5 @spec refresh_cluster(Cluster.t) :: Cluster.t 109 6 def refresh_cluster(%Cluster{} = cluster) do