Skip to content

Home

Development

IDEs

JAR services

API Explorer

Apache ZooKeeper

Martini makes use of the Apache Curator library to connect to an Apache ZooKeeper-managed cluster. The table below describes the related properties and their descriptions:

Property Default Description
zookeeper.url Comma separated host:port pairs. See the Javadoc for the connectString parameter here for more information.
zookeeper.initial-sleep 1000 Initial amount of time to wait (in milliseconds) for after a failed operation before retrying. See the Javadoc for the baseSleepTimeMs parameter here for more information.
zookeeper.retry-limit 3 Maximum number of retry attempts. See the Javadoc for the maxRetries parameter here for more information.
zookeeper.leader-root /toro-martini/leader Location of the node which is used for leader election.
zookeeper.services-root /services Location of the node which is used for storing all available services.
zookeeper.payload Type of payload to use when registering services. If the value of this property is spring-cloud, then the payload will be an instance of org.springframework.cloud.zookeeper.discovery.ZookeeperInstance, which will make Martini compatible with other services in the cluster that are running Spring Cloud, otherwise the payload will be a JSON string.

How to enable ZooKeeper in Martini

The bare minimum to have Martini work with Apache ZooKeeper is to configure the zookeeper.url property. If this property is not configured, Martini will not use any ZooKeeper-specific functionality.

When a Martini instance is connected to Apache ZooKeeper and has gained leadership, Martini will log the following (if enabled):

1
INFO  [ZkLeadershipElector] This node has become the leader, any non-replicated endpoints will now be started