Class CommandClient
- java.lang.Object
- 
- org.apache.zookeeper.server.controller.CommandClient
 
- 
 public class CommandClient extends Object A convenient helper to send controller command to ControllerService.
- 
- 
Constructor SummaryConstructors Constructor Description CommandClient(int localhostPort)CommandClient(int localHostPort, int requestTimeoutInMs)Instantiate a client configured to send requests to localhost.CommandClient(InetSocketAddress hostAddress, int requestTimeoutInMs)Instantiate a client configured to send requests to the specified host address.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()org.eclipse.jetty.client.api.ContentResponsesendCommand(ControlCommand.Action action, String commandParameter)Send a command and optional command parameter to the server and block until receiving a response.booleantrySendCommand(ControlCommand.Action action)Send a command with no parameters to the server and wait for a response.booleantrySendCommand(ControlCommand.Action action, String commandParameter)Send a command with an optional command parameter to the server and wait for a response.
 
- 
- 
- 
Constructor Detail- 
CommandClientpublic CommandClient(int localHostPort, int requestTimeoutInMs)Instantiate a client configured to send requests to localhost.- Parameters:
- localHostPort- Port that the localhost CommandListener is listening on.
- requestTimeoutInMs- Timeout in ms for synchronous requests to timeout.
 
 - 
CommandClientpublic CommandClient(InetSocketAddress hostAddress, int requestTimeoutInMs) Instantiate a client configured to send requests to the specified host address.- Parameters:
- hostAddress- The host address of the listening server.
- requestTimeoutInMs- Timeout in ms for synchronous requests to timeout.
 
 - 
CommandClientpublic CommandClient(int localhostPort) 
 
- 
 - 
Method Detail- 
closepublic void close() 
 - 
trySendCommandpublic boolean trySendCommand(ControlCommand.Action action) Send a command with no parameters to the server and wait for a response. Returns true if we received a good (200) response and false otherwise.
 - 
trySendCommandpublic boolean trySendCommand(ControlCommand.Action action, String commandParameter) Send a command with an optional command parameter to the server and wait for a response.- Parameters:
- action- The command Action to send.
- commandParameter- The command parameter, in the form of command/action/parameter.
- Returns:
- true if we received a good (200) response and false otherwise.
 
 - 
sendCommandpublic org.eclipse.jetty.client.api.ContentResponse sendCommand(ControlCommand.Action action, String commandParameter) throws Exception Send a command and optional command parameter to the server and block until receiving a response.- Parameters:
- action- The command Action to send.
- commandParameter- The command parameter, in the form of command/action/parameter.
- Returns:
- The full response body from the CommandListener server.
- Throws:
- Exception
 
 
- 
 
-