<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->

<!-- 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.namenode.name.dir</name>
        <value><%= node['hadoop']['dfs.namenode.name.dir'] %></value>
        <!-- <value>file://<%= node['grid']['vol_root'] %>/0/var/lib/hdfs/name,file:///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}file://#{node['grid']['vol_root']}/#{vol_num}/var/lib/hdfs/data"
}
-%>
    <property>
        <name>dfs.datanode.data.dir</name>
        <value><%= dfs_data_dir %></value>
        <!-- <value>file:///grid/vol/0/var/lib/hdfs/data,file:///grid/vol/1/var/lib/hdfs/data</value> -->
    </property>
    <property>
        <name>dfs.namenode.checkpoint.dir</name>
        <value><%= node['hadoop']['dfs.namenode.checkpoint.dir'] %></value>
        <!-- <value>file://<%= node['grid']['vol_root'] %>/0/var/lib/hdfs/checkpoint,file:///export/home/hdfs/var/lib/checkpoint</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.namenode.kerberos.principal</name>
        <value><%= node['hadoop']['dfs.namenode.kerberos.principal'] %></value>
        <!-- _HOST is replaced with the fs.defaultFS's host name -->
        <!-- <value>hdfs/${this.namenode.fqdn}@${this.realm}</value> -->
        <description>Kerberos principal name for the NameNode</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.namenode.kerberos.principal</name>
        <value><%= node['hadoop']['dfs.secondary.namenode.kerberos.principal'] %></value>
        <!-- <value>hdfs/_HOST@${this.realm}</value> -->
        <description>
            Kerberos principal name for the secondary NameNode.
        </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>
  <% unless node['hadoop']['install_flavor'] == 'cdh' then -%>
    <!-- for KSSL (NOT RECOMMENDED). Note: N/A on the CDH4 -->
    <property>
        <name>hadoop.security.use-weak-http-crypto</name>
        <value><%= node['hadoop']['hadoop.security.use-weak-http-crypto'] %></value>
    </property>
  <% end -%>
  <% if node['hadoop']['hadoop.security.use-weak-http-crypto'] == 'true' then -%>
    <property>
        <name>dfs.namenode.https-address</name>
        <value><%= node['hadoop']['dfs.namenode.https-address'] %></value>
        <description>The https address where namenode binds</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.secondary.https-address</name>
        <value><%= node['hadoop']['dfs.namenode.secondary.https-address'] %></value>
        <description>The https address where secondary namenode binds</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>
  <% end -%>
    <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.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>HTTP/_HOST@${this.realm}</value> -->
        <!-- _HOST is replaced with dfs.namenode.secondary.http-address's host name. -->
    </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>
<% 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>
