org.apache.nutch.util

## Class NutchTool

- java.lang.Object
- - org.apache.hadoop.conf.Configured
  - - org.apache.nutch.util.NutchTool

- All Implemented Interfaces:
    Configurable
  Direct Known Subclasses:
    CommonCrawlDataDumper, CrawlDb, DeduplicationJob, Fetcher, Generator, IndexingJob, Injector, LinkDb, ParseSegment

      public abstract class NutchTool
      extends Configured

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Job` | `currentJob`
    `protected int` | `currentJobNum`
    `protected int` | `numJobs`
    `protected java.util.HashMap<java.lang.String,java.lang.Object>` | `results`
    `protected java.util.Map<java.lang.String,java.lang.Object>` | `status`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NutchTool()`
    `NutchTool(Configuration conf)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `float` | `getProgress()` Returns relative progress of the tool, a float in range [0,1].
    `java.util.Map<java.lang.String,java.lang.Object>` | `getStatus()` Returns current status of the running tool.
    `boolean` | `killJob()` Kill the job immediately.
    `abstract java.util.Map<java.lang.String,java.lang.Object>` | `run(java.util.Map<java.lang.String,java.lang.Object> args, java.lang.String crawlId)` Runs the tool, using a map of arguments.
    `boolean` | `stopJob()` Stop the job with the possibility to resume.

    - ### Methods inherited from class org.apache.hadoop.conf.Configured

      `getConf, setConf`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### results

          protected java.util.HashMap<java.lang.String,java.lang.Object> results

    - #### status

          protected java.util.Map<java.lang.String,java.lang.Object> status

    - #### currentJob

          protected Job currentJob

    - #### numJobs

          protected int numJobs

    - #### currentJobNum

          protected int currentJobNum

  - ### Constructor Detail

    - #### NutchTool

          public NutchTool(Configuration conf)

    - #### NutchTool

          public NutchTool()

  - ### Method Detail

    - #### run

          public abstract java.util.Map<java.lang.String,java.lang.Object> run(java.util.Map<java.lang.String,java.lang.Object> args,
                                                                               java.lang.String crawlId)
                                                                        throws java.lang.Exception

      Runs the tool, using a map of arguments. May return results, or null.
      Throws:
        `java.lang.Exception`

    - #### getProgress

          public float getProgress()

      Returns relative progress of the tool, a float in range [0,1].

    - #### getStatus

          public java.util.Map<java.lang.String,java.lang.Object> getStatus()

      Returns current status of the running tool.

    - #### stopJob

          public boolean stopJob()
                          throws java.lang.Exception

      Stop the job with the possibility to resume. Subclasses should override this, since by default it calls `killJob()`.
      Returns:
        true if succeeded, false otherwise
      Throws:
        `java.lang.Exception`

    - #### killJob

          public boolean killJob()
                          throws java.lang.Exception

      Kill the job immediately. Clients should assume that any results that the job produced so far are in inconsistent state or missing.
      Returns:
        true if succeeded, false otherwise.
      Throws:
        `java.lang.Exception`

Copyright © 2019 The Apache Software Foundation