<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<!-- Put site-specific property overrides in this file. -->

<configuration>
    <property>
        <name>this.secondary.namenode.fqdn</name>
        <value><%= node['hadoop']['this.secondary.namenode.fqdn'] %></value>
        <!-- <value>${this.cluster.name}-cn.${this.domain}</value> -->
    </property>

    <property>
        <name>dfs.name.dir</name>
        <value><%= node['hadoop']['dfs.name.dir'] %></value>
        <!-- <value><%= node['grid']['vol_root'] %>/0/var/lib/hdfs/name,/export/home/hdfs/var/lib/name</value> -->
    </property>
<%
dfs_data_dir = ''
@active_vol_nums.to_i.times {|vol_num|
  dfs_data_dir = dfs_data_dir == '' ? '' : "#{dfs_data_dir},"
  dfs_data_dir = "#{dfs_data_dir}#{node['grid']['vol_root']}/#{vol_num}/var/lib/hdfs/data"
}
-%>
    <property>
        <name>dfs.data.dir</name>
        <value><%= dfs_data_dir %></value>
        <!-- <value><%= node['grid']['vol_root'] %>/0/var/lib/hdfs/data,<%= node['grid']['vol_root'] %>/1/var/lib/hdfs/data</value> -->
    </property>
    <property>
        <name>dfs.replication</name>
        <value><%= node['hadoop']['dfs.replication'] %></value>
        <!-- <value>3</value> -->
    </property>

    <property>
        <name>dfs.hosts</name>
        <value><%= node['hadoop']['dfs.hosts'] %></value>
        <description>
          Names a file that contains a list of hosts that are permitted to connect to the namenode.
          The full pathname of the file must be specified. If the value is empty, all hosts are permitted.
        </description>
    </property>
    <property>
        <name>dfs.hosts.exclude</name>
        <value><%= node['hadoop']['dfs.hosts.exclude'] %></value>
        <description>
          Names a file that contains a list of hosts that are not permitted to connect to the namenode.
          The full pathname of the file must be specified. If the value is empty, no hosts are excluded.
        </description>
    </property>

<% if node['hadoop']['with_security'] then -%>
    <property>
        <name>dfs.cluster.administrators</name>
        <value><%= node['hadoop']['dfs.cluster.administrators'] %></value>
    </property>
    <property>
        <name>dfs.http.port</name>
        <value><%= node['hadoop']['dfs.http.port'] %></value>
        <description>The http port where namenode binds</description>
    </property>
    <property>
        <name>dfs.http.address</name>
        <value><%= node['hadoop']['dfs.http.address'] %></value>
        <description>The http address where namenode binds</description>
    </property>
    <!-- for KSSL (NOT RECOMMENDED) -->
    <property>
        <name>hadoop.security.use-weak-http-crypto</name>
        <value><%= node['hadoop']['hadoop.security.use-weak-http-crypto'] %></value>
    </property>
  <% if node['hadoop']['hadoop.security.use-weak-http-crypto'] == 'true' then -%>
    <property>
        <name>dfs.https.port</name>
        <value><%= node['hadoop']['dfs.https.port'] %></value>
        <description>The https port where namenode binds</description>
    </property>
    <property>
        <name>dfs.https.address</name>
        <value><%= node['hadoop']['dfs.https.address'] %></value>
        <description>The https address where namenode binds</description>
    </property>
  <% end -%>
    <property>
        <name>dfs.namenode.kerberos.principal</name>
        <value><%= node['hadoop']['dfs.namenode.kerberos.principal'] %></value>
        <!-- _HOST is replaced with the fs.default.name's host name -->
        <!-- <value>hdfs/${this.namenode.fqdn}@${this.realm}</value> -->
        <description>Kerberos principal name for the NameNode</description>
    </property>
    <property>
        <name>dfs.namenode.kerberos.https.principal</name>
        <value><%= node['hadoop']['dfs.namenode.kerberos.https.principal'] %></value>
        <!-- <value>host/_HOST@${this.realm}</value> v1.0.4: NG! -->
        <description>
            The Kerberos principal for the host that the NameNode runs on.
        </description>
    </property>
    <property>
        <name>dfs.namenode.keytab.file</name>
        <value><%= node['hadoop']['dfs.namenode.keytab.file'] %></value>
        <description>
            Combined keytab file containing the namenode service and host
            principals.
        </description>
    </property>
    <property>
        <name>dfs.secondary.http.port</name>
        <value><%= node['hadoop']['dfs.secondary.http.port'] %></value>
        <description>The http port where secondary namenode binds</description>
    </property>
    <property>
        <name>dfs.secondary.http.address</name>
        <value><%= node['hadoop']['dfs.secondary.http.address'] %></value>
        <description>The http address where secondary namenode binds</description>
    </property>
  <% if node['hadoop']['hadoop.security.use-weak-http-crypto'] == 'true' then -%>
    <!-- for KSSL (NOT RECOMMENDED) -->
    <property>
        <name>dfs.secondary.https.port</name>
        <value><%= node['hadoop']['dfs.secondary.https.port'] %></value>
        <description>The https port where secondary namenode binds</description>
    </property>
    <property>
        <name>dfs.secondary.https.address</name>
        <value><%= node['hadoop']['dfs.secondary.https.address'] %></value>
        <description>The https address where secondary namenode binds</description>
    </property>
  <% end -%>
    <property>
        <name>dfs.secondary.namenode.kerberos.principal</name>
        <value><%= node['hadoop']['dfs.secondary.namenode.kerberos.principal'] %></value>
        <!-- <value>hdfs/_HOST@${this.realm}</value> v1.0.4: NG! -->
        <description>
            Kerberos principal name for the secondary NameNode.
        </description>
    </property>
    <property>
        <name>dfs.secondary.namenode.kerberos.https.principal</name>
        <value><%= node['hadoop']['dfs.secondary.namenode.kerberos.https.principal'] %></value>
        <!-- <value>host/_HOST@${this.realm}</value> v1.0.4: NG! -->
        <description>
            The Kerberos principal for the host that the secondary NameNode
            runs on.
        </description>
    </property>
    <property>
        <name>dfs.secondary.namenode.keytab.file</name>
        <value><%= node['hadoop']['dfs.secondary.namenode.keytab.file'] %></value>
        <description>
            Combined keytab file containing the namenode service and host
            principals.
        </description>
    </property>
    <property>
        <name>dfs.block.access.token.enable</name>
        <value><%= node['hadoop']['dfs.block.access.token.enable'] %></value>
        <description>
            If "true", access tokens are used as capabilities for accessing
            datanodes.
            If "false", no access tokens are checked on accessing datanodes.
        </description>
    </property>
    <property>
        <name>dfs.datanode.kerberos.principal</name>
        <value><%= node['hadoop']['dfs.datanode.kerberos.principal'] %></value>
        <!-- <value>hdfs/_HOST@${this.realm}</value> -->
        <description>
            The Kerberos principal that the DataNode runs as. "_HOST" is
            replaced by the real host name.
        </description>
    </property>
    <property>
        <name>dfs.datanode.keytab.file</name>
        <value><%= node['hadoop']['dfs.datanode.keytab.file'] %></value>
        <description>
            The filename of the keytab file for the DataNode.
        </description>
    </property>

    <property>
        <name>dfs.datanode.address</name>
        <value><%= node['hadoop']['dfs.datanode.address'] %></value>
    </property>
    <property>
        <name>dfs.datanode.http.address</name>
        <value><%= node['hadoop']['dfs.datanode.http.address'] %></value>
    </property>

    <property>
        <name>dfs.namenode.http-address</name>
        <value><%= node['hadoop']['dfs.namenode.http-address'] %></value>
    </property>
    <property>
        <name>dfs.namenode.secondary.http-address</name>
        <value><%= node['hadoop']['dfs.namenode.secondary.http-address'] %></value>
    </property>
    <property>
        <name>dfs.web.authentication.kerberos.principal</name>
        <value><%= node['hadoop']['dfs.web.authentication.kerberos.principal'] %></value>
    </property>
    <property>
        <name>dfs.web.authentication.kerberos.keytab</name>
        <value><%= node['hadoop']['dfs.web.authentication.kerberos.keytab'] %></value>
    </property>
    <property>
        <name>dfs.namenode.kerberos.internal.spnego.principal</name>
        <value><%= node['hadoop']['dfs.namenode.kerberos.internal.spnego.principal'] %></value>
        <!-- <value>HTTP/_HOST@${this.realm}</value> -->
        <!-- _HOST is replaced with dfs.namenode.http-address's host name. -->
    </property>
    <property>
        <name>dfs.secondary.namenode.kerberos.internal.spnego.principal</name>
        <value><%= node['hadoop']['dfs.secondary.namenode.kerberos.internal.spnego.principal'] %></value>
        <!-- <value>${dfs.web.authentication.kerberos.principal}</value> -->
        <!-- <value>HTTP/_HOST@${this.realm}</value> -->
        <!-- _HOST is NOT replaced with dfs.namenode.secondary.http-address's host name?! -->
    </property>
<% end -%>
<%
this_file = 'hdfs-site.xml'
if defined? node['hadoop']['extra_configs'][this_file] \
  && node['hadoop']['extra_configs'][this_file] != nil then
  node['hadoop']['extra_configs'][this_file].each do |key,value|
-%>
    <property>
        <name><%= key %></name>
        <value><%= value %></value>
    </property>
<%
  end
end 
-%>
</configuration>
