Package org.apache.drill.yarn.zk
Class ZKClusterCoordinatorDriver
java.lang.Object
org.apache.drill.yarn.zk.ZKClusterCoordinatorDriver
- All Implemented Interfaces:
AMRegistrar
Driver class for the ZooKeeper cluster coordinator. Provides defaults for
most options, but allows customizing each. Provides a
build()
method
to create and start the ZK service. Obtains the initial set of
Drillbits (which should be empty for a YARN-defined cluster) which can be
retrieved after building.
Maintains the ZK connection and monitors for disconnect. This class simply
detects a disconnect timeout, it does not send a disconnect event itself to
avoid creating a timer thread just for this purpose. Instead, the caller can
poll hasFailed()
.
Defaults match those in Drill. (Actual Drill defaults are not yet used due to code incompatibility issues.)
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.drill.yarn.appMaster.AMRegistrar
AMRegistrar.AMRegistrationException
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addDrillbitListener
(DrillbitStatusListener listener) static String
Convenience method to convert a Drillbit to a string.build()
Builds and starts the ZooKeeper cluster coordinator, translating any errors that occur.void
close()
void
static String
Returns the set of Drillbits registered at the time of thebuild()
call.long
boolean
Reports our best guess as to whether ZK has failed.void
void
removeDrillbitListener
(DrillbitStatusListener listener) setConnect
(String connect) Specify connect string in the form: host:/zkRoot/clusterIdsetConnect
(String connect, String zkRoot, String clusterId) setConnectTimeoutMs
(int ms) setFailureTimoutMs
(int ms) setMaxStartWaitMs
(int ms) setPorts
(int userPort, int controlPort, int dataPort) setRetryCount
(int n) setRetryDelayMs
(int ms) protected void
stateChanged
(org.apache.curator.framework.state.ConnectionState newState) Translate ZK connection events into a connected/disconnected state along with the time of the first disconnect not followed by a connect.
-
Constructor Details
-
ZKClusterCoordinatorDriver
public ZKClusterCoordinatorDriver()
-
-
Method Details
-
setConnect
Specify connect string in the form: host:/zkRoot/clusterId- Parameters:
connect
-- Returns:
- This
ZKClusterCoordinatorDriver
. - Throws:
ZKConfigException
-
setConnect
-
setRetryCount
-
setConnectTimeoutMs
-
setRetryDelayMs
-
setMaxStartWaitMs
-
setFailureTimoutMs
-
setPorts
-
build
Builds and starts the ZooKeeper cluster coordinator, translating any errors that occur. After this call, the listener will start receiving messages.- Returns:
- This
ZKClusterCoordinatorDriver
. - Throws:
ZKRuntimeException
- if ZK startup fails
-
addDrillbitListener
-
removeDrillbitListener
-
getInitialEndpoints
Returns the set of Drillbits registered at the time of thebuild()
call. Should be empty for a cluster managed by YARN.- Returns:
- The set of Drillbits registered at the time of the
build()
call.
-
asString
Convenience method to convert a Drillbit to a string. Note that ZK does not advertise the HTTP port, so it does not appear in the generated string.- Parameters:
bit
-- Returns:
- A string representation of a Drillbit.
-
toKey
-
formatKey
-
stateChanged
protected void stateChanged(org.apache.curator.framework.state.ConnectionState newState) Translate ZK connection events into a connected/disconnected state along with the time of the first disconnect not followed by a connect.- Parameters:
newState
-
-
hasFailed
public boolean hasFailed()Reports our best guess as to whether ZK has failed. We assume ZK has failed if we received a connection lost notification without a subsequent connect notification, and we received the disconnect notification log enough ago that we assume that a timeout has occurred.- Returns:
- True if we think zookeeper has failed. False otherwise.
-
getLostConnectionDurationMs
public long getLostConnectionDurationMs() -
close
public void close() -
register
public void register(String amHost, int amPort, String appId) throws AMRegistrar.AMRegistrationException - Specified by:
register
in interfaceAMRegistrar
- Throws:
AMRegistrar.AMRegistrationException
-
deregister
public void deregister()- Specified by:
deregister
in interfaceAMRegistrar
-