org.apache.nutch.api

## Class NutchServer

- java.lang.Object
- - javax.ws.rs.core.Application
  - - org.apache.nutch.api.NutchServer

-     public class NutchServer
      extends javax.ws.rs.core.Application

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `NUTCH_SERVER`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NutchServer()` Public constructor which accepts the port we wish to run the server on as well as the logging granularity.
    `NutchServer(RAMConfManager ramConfManager)` Public constructor which accepts `RAMConfManager` RAM configuration manager and the port we wish to run the server on as well as the logging granularity.
    `NutchServer(RAMConfManager ramConfManager, java.lang.String confId)` Public constructor which accepts `RAMConfManager` RAM configuration manager, a configuration id to use from RAM configuration manager and the port we wish to run the server on as well as the logging granularity.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `canStop(boolean force)` Safety and convenience method to determine whether or not it is safe to shut down the server.
    `java.lang.String` | `getActiveConfId()` Get id of active configuration.
    `java.util.Set<java.lang.Class<?>>` | `getClasses()` Get a set of root resource and provider classes.
    `ConfManager` | `getConfMgr()` Get configuration manager.
    `JobManager` | `getJobMgr()` Get job manager.
    `long` | `getStarted()`
    `boolean` | `isRunning()` Convenience method to determine whether a Nutch server is running.
    `static void` | `main(java.lang.String[] args)` Main method for NutchServer to run via command line.
    `void` | `start()` Starts the Nutch server printing some logging to the log file.
    `boolean` | `stop(boolean force)` Stop the Nutch server.

    - ### Methods inherited from class javax.ws.rs.core.Application

      `getSingletons`

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

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

- - ### Field Detail

    - #### NUTCH_SERVER

          public static final java.lang.String NUTCH_SERVER

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### NutchServer

          public NutchServer()

      Public constructor which accepts the port we wish to run the server on as well as the logging granularity. If the latter option is not provided via `main(String[])` then it defaults to 'INFO' however best attempts should always be made to specify a logging level.<br> `NutchServer` can be run as secure. restapi.auth property should be set to BASIC, DIGEST or SSL at `nutch-site.xml` to enable HTTP basic authentication, digest authentication or SSL when communicating with RESTAPI. Set restapi.auth.username and restapi.auth.password properties at `nutch-site.xml` to configure credentials when BASIC or DIGEST authentication is used. Set restapi.auth.ssl.storepath, restapi.auth.ssl.storepass and restapi.auth.ssl.keypass when SSL is used.
      See Also:
        `AuthenticationTypeEnum`

    - #### NutchServer

          public NutchServer(RAMConfManager ramConfManager)

      Public constructor which accepts `RAMConfManager` RAM configuration manager and the port we wish to run the server on as well as the logging granularity. If the latter option is not provided via `main(String[])` then it defaults to 'INFO' however best attempts should always be made to specify a logging level.<br> `NutchServer` can be run as secure. restapi.auth property should be set to BASIC, DIGEST or SSL at `nutch-site.xml` to enable HTTP basic authentication, digest authentication or SSL when communicating with RESTAPI. Set restapi.auth.username and restapi.auth.password properties at `nutch-site.xml` to configure credentials when BASIC or DIGEST authentication is used. Set restapi.auth.ssl.storepath, restapi.auth.ssl.storepass and restapi.auth.ssl.keypass when SSL is used.
      Parameters:
        `ramConfManager` - `RAMConfManager`
      See Also:
        `AuthenticationTypeEnum`

    - #### NutchServer

          public NutchServer(RAMConfManager ramConfManager,
                             java.lang.String confId)

      Public constructor which accepts `RAMConfManager` RAM configuration manager, a configuration id to use from RAM configuration manager and the port we wish to run the server on as well as the logging granularity. If the latter option is not provided via `main(String[])` then it defaults to 'INFO' however best attempts should always be made to specify a logging level.<br> `NutchServer` can be run as secure. restapi.auth property should be set to BASIC, DIGEST or SSL at `nutch-site.xml` to enable HTTP basic authentication, digest authentication or SSL when communicating with RESTAPI. Set restapi.auth.username and restapi.auth.password properties at `nutch-site.xml` to configure credentials when BASIC or DIGEST authentication is used. Set restapi.auth.ssl.storepath, restapi.auth.ssl.storepass and restapi.auth.ssl.keypass when SSL is used.
      Parameters:
        `ramConfManager` - `RAMConfManager`
        `confId` - active configuration id
      See Also:
        `AuthenticationTypeEnum`

  - ### Method Detail

    - #### getClasses

          public java.util.Set<java.lang.Class<?>> getClasses()

      Get a set of root resource and provider classes. The default lifecycle for resource class instances is per-request. The default lifecycle for providers is singleton.
      Overrides:
        `getClasses` in class `javax.ws.rs.core.Application`
      Returns:
        a set of root resource and provider classes. Returning null is equivalent to returning an empty set.

    - #### getConfMgr

          public ConfManager getConfMgr()

      Get configuration manager.
      Returns:
        configuration manager.

    - #### getJobMgr

          public JobManager getJobMgr()

      Get job manager.
      Returns:
        job manager.

    - #### getActiveConfId

          public java.lang.String getActiveConfId()

      Get id of active configuration.
      Returns:
        active configuration id.

    - #### getStarted

          public long getStarted()

    - #### isRunning

          public boolean isRunning()

      Convenience method to determine whether a Nutch server is running.
      Returns:
        true if a server instance is running.

    - #### start

          public void start()

      Starts the Nutch server printing some logging to the log file.

    - #### canStop

          public boolean canStop(boolean force)

      Safety and convenience method to determine whether or not it is safe to shut down the server. We make this assertion by consulting the `getJobMgr()` for a list of jobs with `JobInfo.state` equal to 'RUNNING'.
      Parameters:
        `force` - ignore running tasks
      Returns:
        true if there are no jobs running or false if there are jobs with running state.

    - #### stop

          public boolean stop(boolean force)

      Stop the Nutch server.
      Parameters:
        `force` - boolean method to effectively kill jobs regardless of state.
      Returns:
        true if no server is running or if the shutdown was successful. Return false if there are running jobs and the force switch has not been activated.

    - #### main

          public static void main(java.lang.String[] args)
                           throws java.lang.Exception

      Main method for NutchServer to run via command line.
      Parameters:
        `args` - arguments for log level, stopping the Server and port.
      Throws:
        `java.lang.Exception` - exception

Copyright © 2019 The Apache Software Foundation