# The number of milliseconds of each tick
tickTime=<%= node['zookeeper']['tickTime'] %>
# The number of ticks that the initial 
# synchronization phase can take
initLimit=<%= node['zookeeper']['initLimit'] %>
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=<%= node['zookeeper']['syncLimit'] %>
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
#dataDir=/tmp/zookeeper
dataDir=<%= node['zookeeper']['dataDirPrefix'] %><%= @node_id == '' ? '' : "/#{@node_id}"%>
<%
dataLogDir = node['zookeeper']['dataLogDir']
if dataLogDir != nil && dataLogDir != '' then
%>
dataLogDir=<%= dataLogDir %>
<% end %>
# the port at which the clients will connect
clientPort=<%= @clientPort %>
<%
if node['zookeeper']['with_security'] then
  node['zookeeper']['authProvider'].each do |id, class_name|
%>
authProvider.<%= id %>=<%= class_name %>
<%
  end
%>
jaasLoginRenew=<%= node['zookeeper']['jaasLoginRenew'] %>
kerberos.removeHostFromPrincipal=<%= node['zookeeper']['kerberos.removeHostFromPrincipal'] %>
kerberos.removeRealmFromPrincipal=<%= node['zookeeper']['kerberos.removeRealmFromPrincipal'] %>
# available?!
#requireClientAuthScheme=sasl
#allowSaslFailedClients=false
#maintain_connection_despite_sasl_failure=false
<% end %>
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

<%
this_file = 'zoo.cfg'
if defined? node['zookeeper']['extra_configs'][this_file] \
  && node['zookeeper']['extra_configs'][this_file] != nil then
  node['zookeeper']['extra_configs'][this_file].each do |key, value|
%>
<%= key %>=<%= value %>
<%
  end
end
%>

<%
case node['zookeeper']['run_mode']
  when 'pseudo-replicated'
%>
# Pseudo ensemble mode on single host
server.0=localhost:2888:3888
server.1=localhost:2889:3889
server.2=localhost:2890:3890
<%
  when 'full-replicated'
    node['zookeeper']['ensemble'].each do |id, server|
%>
server.<%= id %>=<%= server[:hostname] %>:<%= server[:leader_port] %>:<%= server[:election_port] %>
<%
    end
end
%>

