<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You 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.
-->
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">

<document>
  <header>
    <title>POST mapreduce/jar </title>
  </header>

  <body>

  <section>
   <title>Description</title>
    <p>Creates and queues a standard
     <a href="http://hadoop.apache.org/common/docs/current/commands_manual.html">
        Hadoop MapReduce</a> job.</p>
  </section>

  <section>
   <title>URL</title>
    <p><code>http://</code>www.myserver.com<code>/templeton/v1/mapreduce/jar</code></p>
  </section>

  <section>
   <title>Parameters</title>
    <table>
    <tr><th>Name</th><th>Description</th><th>Required?</th><th>Default</th></tr>

    <tr><td><strong>jar</strong></td>
        <td>Name of the jar file for Map Reduce to use.</td>
        <td>Required</td>
        <td>None</td>
    </tr>

    <tr><td><strong>class</strong></td>
        <td>Name of the class for Map Reduce to use.</td>
        <td>Required</td>
        <td>None</td>
    </tr>

    <tr><td><strong>libjars</strong></td>
        <td>Comma separated jar files to include in the classpath.</td>
        <td>Optional</td>
        <td>None</td>
    </tr
>
    <tr><td><strong>files</strong></td>
        <td>Comma separated files to be copied to the map reduce cluster</td>
        <td>Optional</td>
        <td>None</td>
    </tr>

    <tr><td><strong>arg</strong></td>
        <td>Set a program argument.</td>
        <td>Optional</td>
        <td>None</td>
    </tr>

    <tr><td><strong>define</strong></td>
        <td>Set an Hadoop configuration variable using the syntax
         <code>define=NAME=VALUE</code></td>
        <td>Optional</td>
        <td>None</td>
    </tr>

    <tr><td><strong>statusdir</strong></td>
        <td>A directory where Templeton will write the status of the
         Map Reduce job.  If provided, it is the caller's responsibility
         to remove this directory when done.</td>
        <td>Optional</td>
        <td>None</td>
    </tr>

    <tr><td><strong>enablelog</strong></td>
        <td>Collecting hadoop job config and logs into $statusdir/logs folder.
         statusdir must be set as well to use this feature.</td>
        <td>Optional</td>
        <td>None</td>
    </tr>

    <tr><td><strong>callback</strong></td>
        <td>Define a URL to be called upon job completion. You may embed a specific
         job ID into this URL using <code>$jobId</code>.  This tag
         will be replaced in the callback URL with this job's job ID.</td>
        <td>Optional</td>
        <td>None</td>
    </tr>
    </table>
  </section>

  <section>
   <title>Results</title>
     <table>
      <tr><th>Name</th><th>Description</th></tr>

      <tr><td><strong>id</strong></td>
        <td>A string containing the job ID similar to "job_201110132141_0001".</td>
      </tr>

      <tr><td><strong>info</strong></td>
        <td>A JSON object containing the information returned when the job was queued.
            See the Hadoop documentation
            (<a href="http://hadoop.apache.org/common/docs/stable/api/org/apache/hadoop/mapred/TaskController.html">Class
            TaskController</a>) for more information.</td>
      </tr>
     </table>
  </section>

  <section>
   <title>Example</title>

   <p><strong>Code and Data Setup</strong></p>
<source>
% hadoop fs -put wordcount.jar .
% hadoop fs -put transform.jar .

% hadoop fs -ls .
Found 2 items
-rw-r--r--   1 ctdean supergroup         23 2011-11-11 13:29 /user/ctdean/wordcount.jar
-rw-r--r--   1 ctdean supergroup         28 2011-11-11 13:29 /user/ctdean/transform.jar
</source>

   <p><strong>Curl Command</strong></p>
<source>
% curl -s -d user.name=ctdean \
       -d jar=wordcount.jar \
       -d class=org.myorg.WordCount \
       -d libjars=transform.jar \
       -d arg=wordcount/input \
       -d arg=wordcount/output \
       'http://localhost:50111/templeton/v1/mapreduce/jar'
</source>

   <p><strong>JSON Output</strong></p>
<source>
{
 "id": "job_201111121211_0001",
 "info": {
          "stdout": "templeton-job-id:job_201111121211_0001
                    ",
          "stderr": "",
          "exitcode": 0
         }
}
</source>
  </section>
  </body>
</document>
