# Class JettyAdminServer

java.lang.Object
org.apache.zookeeper.server.admin.JettyAdminServer

All Implemented Interfaces:
  `AdminServer`

public class JettyAdminServer extends Object implements AdminServer
This class encapsulates a Jetty server for running Commands. Given the default settings, start a ZooKeeper server and visit http://hostname:8080/commands for links to all registered commands. Visiting http://hostname:8080/commands/commandname will execute the associated Command and return the result in the body of the response. Any keyword arguments to the command are specified with URL parameters (e.g., http://localhost:8080/commands/set_trace_mask?traceMask=306).

See Also:
  - `Commands`
  - `CommandOutputter`

## Nested Class Summary

### Nested classes/interfaces inherited from interface AdminServer

`AdminServer.AdminServerException`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`DEFAULT_COMMAND_URL`
`static final int`
`DEFAULT_HTTP_VERSION`
`static final int`
`DEFAULT_IDLE_TIMEOUT`
`static final int`
`DEFAULT_PORT`
`static final int`
`DEFAULT_STS_MAX_AGE`

## Constructor Summary

Constructors
Constructor
Description
`JettyAdminServer()`
`JettyAdminServer(String address, int port, int timeout, String commandUrl, int httpVersion, boolean portUnification, boolean forceHttps, boolean needClientAuth)`

## Method Summary

Modifier and Type
Method
Description
`void`
`setZooKeeperServer(ZooKeeperServer zkServer)`
Set the ZooKeeperServer that will be used to run Commands.
`void`
`shutdown()`
Stop the embedded Jetty server.
`void`
`start()`
Start the embedded Jetty server.

### Methods inherited from class Object

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

## Field Details

### DEFAULT_PORT

public static final int DEFAULT_PORT

See Also:
  - Constant Field Values

### DEFAULT_IDLE_TIMEOUT

public static final int DEFAULT_IDLE_TIMEOUT

See Also:
  - Constant Field Values

### DEFAULT_COMMAND_URL

public static final String DEFAULT_COMMAND_URL

See Also:
  - Constant Field Values

### DEFAULT_STS_MAX_AGE

public static final int DEFAULT_STS_MAX_AGE

See Also:
  - Constant Field Values

### DEFAULT_HTTP_VERSION

public static final int DEFAULT_HTTP_VERSION

See Also:
  - Constant Field Values

## Constructor Details

### JettyAdminServer

public JettyAdminServer() throws AdminServer.AdminServerException, IOException, GeneralSecurityException

Throws:
  `AdminServer.AdminServerException`
  `IOException`
  `GeneralSecurityException`

### JettyAdminServer

public JettyAdminServer(String address, int port, int timeout, String commandUrl, int httpVersion, boolean portUnification, boolean forceHttps, boolean needClientAuth) throws IOException, GeneralSecurityException

Throws:
  `IOException`
  `GeneralSecurityException`

## Method Details

### start

public void start() throws AdminServer.AdminServerException
Start the embedded Jetty server.

Specified by:
  `start` in interface `AdminServer`
Throws:
  `AdminServer.AdminServerException`

### shutdown

public void shutdown() throws AdminServer.AdminServerException
Stop the embedded Jetty server. This is not very important except for tests where multiple JettyAdminServers are started and may try to bind to the same ports if previous servers aren't shut down.

Specified by:
  `shutdown` in interface `AdminServer`
Throws:
  `AdminServer.AdminServerException`

### setZooKeeperServer

public void setZooKeeperServer(ZooKeeperServer zkServer)
Set the ZooKeeperServer that will be used to run Commands. It is not necessary to set the ZK server before calling AdminServer.start(), and the ZK server can be set to null when, e.g., that server is being shut down. If the ZK server is not set or set to null, the AdminServer will still be able to issue Commands, but they will return an error until a ZK server is set.

Specified by:
  `setZooKeeperServer` in interface `AdminServer`