Skip to content

Commit

Permalink
Merge pull request #7 from apache/master
Browse files Browse the repository at this point in the history
Merging Latest Master
  • Loading branch information
arankin-irl authored Jan 25, 2019
2 parents 75a010e + 0f44fd9 commit 5a9b8fc
Show file tree
Hide file tree
Showing 30 changed files with 1,173 additions and 162 deletions.
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ xmlns:cs="antlib:com.puppycrawl.tools.checkstyle.ant">
<!-- ====================================================== -->
<property name="slf4j.version" value="1.7.25"/>
<property name="commons-cli.version" value="1.2"/>
<property name="spotbugsannotations.version" value="3.1.8"/>
<property name="spotbugsannotations.version" value="3.1.9"/>

<property name="wagon-http.version" value="2.4"/>
<property name="maven-ant-tasks.version" value="2.1.3"/>
Expand Down
10 changes: 8 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@
<kerby.version>1.1.0</kerby.version>
<bouncycastle.version>1.56</bouncycastle.version>
<commons-collections.version>3.2.2</commons-collections.version>
<spotbugsannotations.version>3.1.8</spotbugsannotations.version>
<commons-lang.version>2.6</commons-lang.version>
<spotbugsannotations.version>3.1.9</spotbugsannotations.version>
</properties>

<dependencyManagement>
Expand All @@ -293,6 +294,11 @@
<artifactId>commons-collections</artifactId>
<version>${commons-collections.version}</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commons-lang.version}</version>
</dependency>
<dependency>
<groupId>org.apache.yetus</groupId>
<artifactId>audience-annotations</artifactId>
Expand Down Expand Up @@ -472,7 +478,7 @@
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>3.1.8</version>
<version>3.1.9</version>
<configuration>
<excludeFilterFile>excludeFindBugsFilter.xml</excludeFilterFile>
</configuration>
Expand Down
18 changes: 16 additions & 2 deletions zookeeper-contrib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,25 @@
<description>
Contrib projects to Apache ZooKeeper
</description>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>3.1.9</version>
<configuration>
<!-- No spotbugs for contri modules -->
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<modules>
<module>zookeeper-contrib-loggraph</module>
<module>zookeeper-contrib-rest</module>
<module>zookeeper-contrib-zooinspector</module>
</modules>

</project>
</project>
86 changes: 86 additions & 0 deletions zookeeper-docs/src/main/resources/markdown/zookeeperAdmin.md
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,92 @@ property, when available, is noted below.
of the observers on restart. Set to "false" to disable this
feature. Default is "true"

* *fastleader.minNotificationInterval* :
(Java system property: **zookeeper.fastleader.minNotificationInterval**)
Lower bound for length of time between two consecutive notification
checks on the leader election. This interval determines how long a
peer waits to check the set of election votes and effects how
quickly an election can resolve. The interval follows a backoff
strategy from the configured minimum (this) and the configured maximum
(fastleader.maxNotificationInterval) for long elections.

* *fastleader.maxNotificationInterval* :
(Java system property: **zookeeper.fastleader.maxNotificationInterval**)
Upper bound for length of time between two consecutive notification
checks on the leader election. This interval determines how long a
peer waits to check the set of election votes and effects how
quickly an election can resolve. The interval follows a backoff
strategy from the configured minimum (fastleader.minNotificationInterval)
and the configured maximum (this) for long elections.

* *connectionMaxTokens* :
(Java system property: **zookeeper.connection_throttle_tokens**)
**New in 3.6.0:**
This is one of the parameters to tune the server-side connection throttler,
which is a token-based rate limiting mechanism with optional probabilistic
dropping.
This parameter defines the maximum number of tokens in the token-bucket.
When set to 0, throttling is disabled. Default is 0.

* *connectionTokenFillTime* :
(Java system property: **zookeeper.connection_throttle_fill_time**)
**New in 3.6.0:**
This is one of the parameters to tune the server-side connection throttler,
which is a token-based rate limiting mechanism with optional probabilistic
dropping.
This parameter defines the interval in milliseconds when the token bucket is re-filled with
*connectionTokenFillCount* tokens. Default is 1.

* *connectionTokenFillCount* :
(Java system property: **zookeeper.connection_throttle_fill_count**)
**New in 3.6.0:**
This is one of the parameters to tune the server-side connection throttler,
which is a token-based rate limiting mechanism with optional probabilistic
dropping.
This parameter defines the number of tokens to add to the token bucket every
*connectionTokenFillTime* milliseconds. Default is 1.

* *connectionFreezeTime* :
(Java system property: **zookeeper.connection_throttle_freeze_time**)
**New in 3.6.0:**
This is one of the parameters to tune the server-side connection throttler,
which is a token-based rate limiting mechanism with optional probabilistic
dropping.
This parameter defines the interval in milliseconds when the dropping
probability is adjusted. When set to -1, probabilistic dropping is disabled.
Default is -1.

* *connectionDropIncrease* :
(Java system property: **zookeeper.connection_throttle_drop_increase**)
**New in 3.6.0:**
This is one of the parameters to tune the server-side connection throttler,
which is a token-based rate limiting mechanism with optional probabilistic
dropping.
This parameter defines the dropping probability to increase. The throttler
checks every *connectionFreezeTime* milliseconds and if the token bucket is
empty, the dropping probability will be increased by *connectionDropIncrease*.
The default is 0.02.

* *connectionDropDecrease* :
(Java system property: **zookeeper.connection_throttle_drop_decrease**)
**New in 3.6.0:**
This is one of the parameters to tune the server-side connection throttler,
which is a token-based rate limiting mechanism with optional probabilistic
dropping.
This parameter defines the dropping probability to decrease. The throttler
checks every *connectionFreezeTime* milliseconds and if the token bucket has
more tokens than a threshold, the dropping probability will be decreased by
*connectionDropDecrease*. The threshold is *connectionMaxTokens* \*
*connectionDecreaseRatio*. The default is 0.002.

* *connectionDecreaseRatio* :
(Java system property: **zookeeper.connection_throttle_decrease_ratio**)
**New in 3.6.0:**
This is one of the parameters to tune the server-side connection throttler,
which is a token-based rate limiting mechanism with optional probabilistic
dropping. This parameter defines the threshold to decrease the dropping
probability. The default is 0.

<a name="sc_clusterOptions"></a>

#### Cluster Options
Expand Down
2 changes: 1 addition & 1 deletion zookeeper-recipes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@
<module>zookeeper-recipes-queue</module>
</modules>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -180,27 +180,36 @@ private void makeOffer() throws KeeperException, InterruptedException {
state = State.OFFER;
dispatchEvent(EventType.OFFER_START);

leaderOffer = new LeaderOffer();

leaderOffer.setHostName(hostName);
leaderOffer.setNodePath(zooKeeper.create(rootNodeName + "/" + "n_",
hostName.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE,
LeaderOffer newLeaderOffer = new LeaderOffer();
byte[] hostnameBytes;
synchronized (this) {
newLeaderOffer.setHostName(hostName);
hostnameBytes = hostName.getBytes();
newLeaderOffer.setNodePath(zooKeeper.create(rootNodeName + "/" + "n_",
hostnameBytes, ZooDefs.Ids.OPEN_ACL_UNSAFE,
CreateMode.EPHEMERAL_SEQUENTIAL));

leaderOffer = newLeaderOffer;
}
logger.debug("Created leader offer {}", leaderOffer);

dispatchEvent(EventType.OFFER_COMPLETE);
}

private synchronized LeaderOffer getLeaderOffer() {
return leaderOffer;
}

private void determineElectionStatus() throws KeeperException,
InterruptedException {

state = State.DETERMINE;
dispatchEvent(EventType.DETERMINE_START);

String[] components = leaderOffer.getNodePath().split("/");
LeaderOffer currentLeaderOffer = getLeaderOffer();

String[] components = currentLeaderOffer.getNodePath().split("/");

leaderOffer.setId(Integer.valueOf(components[components.length - 1]
currentLeaderOffer.setId(Integer.valueOf(components[components.length - 1]
.substring("n_".length())));

List<LeaderOffer> leaderOffers = toLeaderOffers(zooKeeper.getChildren(
Expand All @@ -215,7 +224,7 @@ private void determineElectionStatus() throws KeeperException,
for (int i = 0; i < leaderOffers.size(); i++) {
LeaderOffer leaderOffer = leaderOffers.get(i);

if (leaderOffer.getId().equals(this.leaderOffer.getId())) {
if (leaderOffer.getId().equals(currentLeaderOffer.getId())) {
logger.debug("There are {} leader offers. I am {} in line.",
leaderOffers.size(), i);

Expand All @@ -237,7 +246,7 @@ private void becomeReady(LeaderOffer neighborLeaderOffer)
throws KeeperException, InterruptedException {

logger.info("{} not elected leader. Watching node:{}",
leaderOffer.getNodePath(), neighborLeaderOffer.getNodePath());
getLeaderOffer().getNodePath(), neighborLeaderOffer.getNodePath());

/*
* Make sure to pass an explicit Watcher because we could be sharing this
Expand Down Expand Up @@ -270,7 +279,7 @@ private void becomeLeader() {
state = State.ELECTED;
dispatchEvent(EventType.ELECTED_START);

logger.info("Becoming leader with node:{}", leaderOffer.getNodePath());
logger.info("Becoming leader with node:{}", getLeaderOffer().getNodePath());

dispatchEvent(EventType.ELECTED_COMPLETE);
}
Expand Down Expand Up @@ -336,7 +345,7 @@ private List<LeaderOffer> toLeaderOffers(List<String> strings)
@Override
public void process(WatchedEvent event) {
if (event.getType().equals(Watcher.Event.EventType.NodeDeleted)) {
if (!event.getPath().equals(leaderOffer.getNodePath())
if (!event.getPath().equals(getLeaderOffer().getNodePath())
&& state != State.STOP) {
logger.debug(
"Node {} deleted. Need to run through the election process.",
Expand Down Expand Up @@ -384,8 +393,8 @@ public void removeListener(LeaderElectionAware listener) {

@Override
public String toString() {
return "{ state:" + state + " leaderOffer:" + leaderOffer + " zooKeeper:"
+ zooKeeper + " hostName:" + hostName + " listeners:" + listeners
return "{ state:" + state + " leaderOffer:" + getLeaderOffer() + " zooKeeper:"
+ zooKeeper + " hostName:" + getHostName() + " listeners:" + listeners
+ " }";
}

Expand Down Expand Up @@ -437,11 +446,11 @@ public void setZooKeeper(ZooKeeper zooKeeper) {
* The hostname of this process. Mostly used as a convenience for logging and
* to respond to {@link #getLeaderHostName()} requests.
*/
public String getHostName() {
public synchronized String getHostName() {
return hostName;
}

public void setHostName(String hostName) {
public synchronized void setHostName(String hostName) {
this.hostName = hostName;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.zookeeper.recipes.leader;

import java.io.Serializable;
import java.util.Comparator;

/**
Expand Down Expand Up @@ -72,7 +73,8 @@ public void setHostName(String hostName) {
* Compare two instances of {@link LeaderOffer} using only the {code}id{code}
* member.
*/
public static class IdComparator implements Comparator<LeaderOffer> {
public static class IdComparator
implements Comparator<LeaderOffer>, Serializable {

@Override
public int compare(LeaderOffer o1, LeaderOffer o2) {
Expand Down
9 changes: 8 additions & 1 deletion zookeeper-recipes/zookeeper-recipes-lock/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
<artifactId>zookeeper-server</artifactId>
<version>3.6.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
<version>3.1.9</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper-server</artifactId>
Expand Down Expand Up @@ -71,4 +78,4 @@
</plugins>
</build>

</project>
</project>
Loading

0 comments on commit 5a9b8fc

Please sign in to comment.