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

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

<configuration>
    <property>
        <name>this.cluster.name</name>
        <value><%= node['hadoop']['this.cluster.name'] %></value>
        <!-- <value>pleiades</value> -->
    </property>
    <property>
        <name>this.domain</name>
        <value><%= node['hadoop']['this.domain'] %></value>
        <!-- <value>grid.example.com</value> -->
    </property>
<% if node['hadoop']['with_security'] then -%>
    <property>
        <name>this.realm</name>
        <value><%= node['hadoop']['this.realm'] %></value>
        <!-- <value>GRID.EXAMPLE.COM</value> -->
    </property>
    <property>
        <name>this.keytab.dir</name>
        <value><%= node['hadoop']['this.keytab.dir'] %></value>
    </property>
<% end -%>
    <property>
        <name>this.namenode.fqdn</name>
        <value><%= node['hadoop']['this.namenode.fqdn'] %></value>
        <!-- <value>${this.cluster.name}-nn.${this.domain}</value> -->
    </property>

    <property>
        <name>fs.default.name</name>
        <value><%= node['hadoop']['fs.default.name'] %></value>
    </property>
    <property>
        <name>hadoop.tmp.dir</name>
        <value><%= node['hadoop']['hadoop.tmp.dir'] %></value>
    </property>
    <property>
        <name>fs.checkpoint.dir</name>
        <value><%= node['hadoop']['fs.checkpoint.dir'] %></value>
        <!-- <value><%= node['grid']['vol_root'] %>/0/var/lib/${user.name}/checkpoint,/export/home/${user.name}/var/lib/checkpoint</value> -->
    </property>

<% if node['hadoop']['with_security'] then -%>
    <property>
        <name>hadoop.security.authentication</name>
        <value><%= node['hadoop']['hadoop.security.authentication'] %></value>
        <description>
            Set the authentication for the cluster. Valid values are: simple or
            kerberos.
        </description>
    </property>
    <property>
        <name>hadoop.security.authorization</name>
        <value><%= node['hadoop']['hadoop.security.authorization'] %></value>
        <description>
            Enable authorization for different protocols.
        </description>
    </property>
    <property>
        <name>hadoop.security.auth_to_local</name>
        <value><%= node['hadoop']['hadoop.security.auth_to_local'] %></value>
    </property>
    <property>
        <name>hadoop.security.group.mapping</name>
        <value><%= node['hadoop']['hadoop.security.group.mapping'] %></value>
    </property>
    <property>
        <name>hadoop.security.groups.cache.secs</name>
        <value><%= node['hadoop']['hadoop.security.groups.cache.secs'] %></value>
    </property>
    <property>
        <name>hadoop.kerberos.kinit.command</name>
        <value><%= node['hadoop']['hadoop.kerberos.kinit.command'] %></value>
    </property>

    <property>
        <name>hadoop.http.filter.initializers</name>
        <value><%= node['hadoop']['hadoop.http.filter.initializers'] %></value>
        <!-- <value>org.apache.hadoop.http.lib.StaticUserWebFilter</value> -->
        <description>The name of a class that initializes an input filter for Jetty.
            This filter will always return Dr.Who as the web user when the servlets
            query for the authenticated user </description>
    </property>
    <property>
        <name>hadoop.http.authentication.signature.secret.file</name>
        <value><%= node['hadoop']['hadoop.http.authentication.signature.secret.file'] %></value>
    </property>
    <property>
        <name>hadoop.http.authentication.cookie.domain</name>
        <value><%= node['hadoop']['hadoop.http.authentication.cookie.domain'] %></value>
    </property>
    <property>
        <name>hadoop.http.authentication.type</name>
        <value><%= node['hadoop']['hadoop.http.authentication.type'] %></value>
        <description>Defines authentication used for the HTTP web-consoles.
            The supported values are: simple | kerberos | #AUTHENTICATION_HANDLER_CLASSNAME#.
            The dfeault value is simple.</description>
    </property>
    <property>
        <name>hadoop.http.authentication.kerberos.principal</name>
        <value><%= node['hadoop']['hadoop.http.authentication.kerberos.principal'] %></value>
        <!-- <value>HTTP/_HOST@${this.realm}</value>
            _HOST N/A!: v1.0, v1.1, v1.2, HDP1.2, 1.3; OK: v2.0, CDH3, CDH4 -->
        <!-- in the _HOST N/A environments.
        <value>HTTP/${this.fqdn}@${this.realm}</value>
        "this".fqdn must be set in the conf/hadoop-env.sh
        or each setting
        <value>HTTP/${this.cluster.name}-nn.${this.domain}@${this.realm}</value>
        <value>HTTP/${this.cluster.name}-cn.${this.domain}@${this.realm}</value>
        <value>HTTP/${this.cluster.name}-jt.${this.domain}@${this.realm}</value>
        <value>HTTP/${this.cluster.name}-jh.${this.domain}@${this.realm}</value>
        <value>HTTP/dn00000.${this.domain}@${this.realm}</value>
        <value>HTTP/dn00001.${this.domain}@${this.realm}</value>
        -->
    </property>
    <property>
        <name>hadoop.http.authentication.kerberos.keytab</name>
        <value><%= node['hadoop']['hadoop.http.authentication.kerberos.keytab'] %></value>
    </property>

  <%- node['hadoop']['hadoop.proxyuser'].each do |name, values| -%>
    <property>
        <name>hadoop.proxyuser.<%= name %>.hosts</name>
        <value><%= values['hosts'] %></value>
    </property>
    <property>
        <name>hadoop.proxyuser.<%= name %>.groups</name>
        <value><%= values['groups'] %></value>
    </property>
  <%- end -%>
<% end -%>
<%
this_file = 'core-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>
