public class EmbeddedZooKeeper
extends java.lang.Object
implements org.springframework.context.SmartLifecycle
SingleNodeApplication
Constructor and Description |
---|
EmbeddedZooKeeper()
Construct an EmbeddedZooKeeper with a random port.
|
EmbeddedZooKeeper(int clientPort)
Construct an EmbeddedZooKeeper with the provided port.
|
Modifier and Type | Method and Description |
---|---|
int |
getClientPort()
Returns the port that clients should use to connect to this embedded server.
|
int |
getPhase() |
boolean |
isAutoStartup() |
boolean |
isRunning() |
void |
setAutoStartup(boolean autoStartup)
Specify whether to start automatically.
|
void |
setErrorHandler(org.springframework.util.ErrorHandler errorHandler)
Provide an
ErrorHandler to be invoked if an Exception is thrown from the ZooKeeper server thread. |
void |
setPhase(int phase)
Specify the lifecycle phase for the embedded server.
|
void |
start()
Start the ZooKeeper server in a background thread.
|
void |
stop()
Shutdown the ZooKeeper server.
|
void |
stop(java.lang.Runnable callback)
Stop the server if running and invoke the callback when complete.
|
public EmbeddedZooKeeper()
public EmbeddedZooKeeper(int clientPort)
clientPort
- port for ZooKeeper server to bind topublic int getClientPort()
public void setAutoStartup(boolean autoStartup)
autoStartup
- whether to start automaticallypublic boolean isAutoStartup()
isAutoStartup
in interface org.springframework.context.SmartLifecycle
public void setPhase(int phase)
phase
- the lifecycle phasepublic int getPhase()
getPhase
in interface org.springframework.context.Phased
public boolean isRunning()
isRunning
in interface org.springframework.context.Lifecycle
public void start()
Register an error handler via setErrorHandler(org.springframework.util.ErrorHandler)
in order to handle
any exceptions thrown during startup or execution.
start
in interface org.springframework.context.Lifecycle
public void stop()
stop
in interface org.springframework.context.Lifecycle
public void stop(java.lang.Runnable callback)
stop
in interface org.springframework.context.SmartLifecycle
public void setErrorHandler(org.springframework.util.ErrorHandler errorHandler)
ErrorHandler
to be invoked if an Exception is thrown from the ZooKeeper server thread. If none
is provided, only error-level logging will occur.errorHandler
- the ErrorHandler
to be invoked