0

I have the following value im my application my_app.pp value:

akka_application_cluster_seed_nodes => '"akka.tcp://ActorSystem@host1:2551","akka.tcp://ActorSystem@host2:2551","akka.tcp://ActorSystem@host3:2551"'

Now in my erb file min-nr-of-members value should be calculated by getting the size of akka_application_cluster_seed_nodes array divide by 2 plus 1

 $min-nr-of-members = $akka_application_cluster_seed_nodes.size/2 +1

For example:

  auto-down-unreachable-after = <%= get_param('akka_cluster_auto_down_unreachable_after')%>

and something like this:
      <% $cluster= get_param('akka_cluster_auto_down_unreachable_after') %>
      <% $minNumOfNodes = ($cluster.size / 2)+1 %>

min-nr-of-members = <% $minNumOfNodes %>
030
  • 5,901
  • 13
  • 68
  • 110
danny.lesnik
  • 135
  • 1
  • 5

1 Answers1

3

This should do the trick:

<% minNumOfNodes = (@akka_application_cluster_seed_nodes.split(',').length / 2)+1 %>
min-nr-of-members = <%=minNumOfNodes%>

Inside the <% %> it is just straight Ruby, so we take the raw string, split it on the comma, take the count, then do the required calculation on that.

Craig Miskell
  • 4,216
  • 1
  • 16
  • 16