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

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

<configuration>
    <property>
        <name>this.jobtracker.fqdn</name>
        <value><%= node['hadoop']['this.jobtracker.fqdn'] %></value>
        <!-- <value>${this.cluster.name}-jt.${this.domain}</value> -->
    </property>
    <property>
        <name>this.jobhistory.fqdn</name>
        <value><%= node['hadoop']['this.jobhistory.fqdn'] %></value>
        <!-- <value>${this.cluster.name}-jt.${this.domain}</value> -->
        <!-- <value>${this.cluster.name}-jh.${this.domain}</value> -->
    </property>

    <property>
        <name>mapred.job.tracker</name>
        <value><%= node['hadoop']['mapred.job.tracker'] %></value>
    </property>
    <property>
        <name>mapred.system.dir</name>
        <value><%= node['hadoop']['mapred.system.dir'] %></value>
    </property>
    <property>
        <name>mapreduce.jobtracker.staging.root.dir</name>
        <value><%= node['hadoop']['mapreduce.jobtracker.staging.root.dir'] %></value>
    </property>

    <property>
        <name>mapred.job.tracker.persist.jobstatus.active</name>
        <value><%= node['hadoop']['mapred.job.tracker.persist.jobstatus.active'] %></value>
        <description>Indicates if persistency of job status information is
          active or not. (default: false)
        </description>
    </property>
    <property>
        <name>mapred.job.tracker.persist.jobstatus.hours</name>
        <value><%= node['hadoop']['mapred.job.tracker.persist.jobstatus.hours'] %></value>
        <description>The number of hours job status information is persisted in DFS.
          The job status information will be available after it drops of the memory
          queue and between jobtracker restarts. With a zero value the job status
          information is not persisted at all in DFS. (default: 0)
        </description>
    </property>
    <property>
        <name>mapred.job.tracker.persist.jobstatus.dir</name>
        <value><%= node['hadoop']['mapred.job.tracker.persist.jobstatus.dir'] %></value>
        <description>The directory where the job status information is persisted
          in a file system to be available after it drops of the memory queue and
          between jobtracker restarts. (default: /jobtracker/jobsInfo)
        </description>
    </property>

    <property>
        <name>hadoop.job.history.location</name>
        <value><%= node['hadoop']['hadoop.job.history.location'] %></value>
        <description>hdfs:// is UNusable.</description>
    </property>
    <property>
        <name>mapred.job.tracker.history.completed.location</name>
        <value><%= node['hadoop']['mapred.job.tracker.history.completed.location'] %></value>
    </property>

<%
mapred_local_dir = ''
@active_vol_nums.to_i.times {|vol_num|
  mapred_local_dir = mapred_local_dir == '' ? '' : "#{mapred_local_dir},"
  mapred_local_dir = "#{mapred_local_dir}#{node['grid']['vol_root']}/#{vol_num}/var/lib/mapred/local"
}
-%>
    <property>
        <name>mapred.local.dir</name>
        <value><%= mapred_local_dir %></value>
        <!-- <value><%= node['grid']['vol_root'] %>/0/var/lib/mapred/local,<%= node['grid']['vol_root'] %>/1/var/lib/mapred/local</value> -->
        <description>
          The local directory where MapReduce stores intermediate data files.
          May be a comma-separated list of directories on different devices in order to spread disk i/o.
          Directories that do not exist are ignored.
        </description>
    </property>
<%
mapred_temp_dir = ''
@active_vol_nums.to_i.times {|vol_num|
  mapred_temp_dir = mapred_temp_dir == '' ? '' : "#{mapred_temp_dir},"
  mapred_temp_dir = "#{mapred_temp_dir}#{node['grid']['vol_root']}/#{vol_num}/tmp/${user.name}/mapred"
}
-%>
    <property>
        <name>mapred.temp.dir</name>
        <value><%= mapred_temp_dir %></value>
        <!-- <value><%= node['grid']['vol_root'] %>/0/tmp/${user.name}/mapred,<%= node['grid']['vol_root'] %>/1/tmp/${user.name}/mapred</value> -->
        <description>
          A shared directory for temporary files.
        </description>
    </property>

    <property>
        <name>mapred.hosts</name>
        <value><%= node['hadoop']['mapred.hosts'] %></value>
        <description>
          Names a file that contains the list of nodes that may connect to the jobtracker.
          If the value is empty, all hosts are permitted.
        </description>
    </property>
    <property>
        <name>mapred.hosts.exclude</name>
        <value><%= node['hadoop']['mapred.hosts.exclude'] %></value>
        <description>
          Names a file that contains the list of hosts that should be excluded by the jobtracker.
          If the value is empty, no hosts are excluded.
        </description>
    </property>

    <property>
        <name>mapred.jobtracker.taskScheduler</name>
        <value><%= node['hadoop']['mapred.jobtracker.taskScheduler'] %></value>
    </property>

<% if node['hadoop']['with_security'] then -%>
    <property>
        <name>mapred.acls.enabled</name>
        <value><%= node['hadoop']['mapred.acls.enabled'] %></value>
    </property>
    <property>
        <name>mapreduce.cluster.administrators</name>
        <value><%= node['hadoop']['mapreduce.cluster.administrators'] %></value>
    </property>
    <property>
        <name>mapreduce.jobtracker.kerberos.principal</name>
        <value><%= node['hadoop']['mapreduce.jobtracker.kerberos.principal'] %></value>
        <!-- _HOST is replaced with the mapred.job.tracker's host name -->
        <!-- <value>mapred/${this.jobtracker.fqdn}@${this.realm}</value> -->
    </property>
    <property>
        <name>mapreduce.jobtracker.keytab.file</name>
        <value><%= node['hadoop']['mapreduce.jobtracker.keytab.file'] %></value>
    </property>
    <property>
        <name>mapreduce.tasktracker.kerberos.principal</name>
        <value><%= node['hadoop']['mapreduce.tasktracker.kerberos.principal'] %></value>
        <!-- <value>mapred/_HOST@${this.realm}</value> -->
    </property>
    <property>
        <name>mapreduce.tasktracker.keytab.file</name>
        <value><%= node['hadoop']['mapreduce.tasktracker.keytab.file'] %></value>
    </property>

    <property>
        <name>mapred.task.tracker.task-controller</name>
        <value><%= node['hadoop']['mapred.task.tracker.task-controller'] %></value>
    </property>

    <property>
        <name>mapreduce.history.server.embedded</name>
        <value><%= node['hadoop']['mapreduce.history.server.embedded'] %></value>
        <!-- <value>false</value> -->
    </property>
    <property>
        <name>mapreduce.history.server.http.address</name>
        <value><%= node['hadoop']['mapreduce.history.server.http.address'] %></value>
    </property>
    <property>
        <name>mapreduce.jobhistory.kerberos.principal</name>
        <value><%= node['hadoop']['mapreduce.jobhistory.kerberos.principal'] %></value>
    </property>
    <property>
        <name>mapreduce.jobhistory.keytab.file</name>
        <value><%= node['hadoop']['mapreduce.jobhistory.keytab.file'] %></value>
    </property>
<% end -%>
<%
this_file = 'mapred-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>
