You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tr...@apache.org on 2018/01/26 14:41:34 UTC

[08/16] flink git commit: [hotfix] Fix checkstyle violations in ZooKeeperLeaderElectionService

[hotfix] Fix checkstyle violations in ZooKeeperLeaderElectionService


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/3ea6be23
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/3ea6be23
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/3ea6be23

Branch: refs/heads/master
Commit: 3ea6be23d672991b4addc2d7b6322e15ddb2efa1
Parents: 60f98df
Author: gyao <ga...@data-artisans.com>
Authored: Mon Jan 15 12:26:47 2018 +0100
Committer: Till Rohrmann <tr...@apache.org>
Committed: Fri Jan 26 13:50:22 2018 +0100

----------------------------------------------------------------------
 .../ZooKeeperLeaderElectionService.java          | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/3ea6be23/flink-runtime/src/main/java/org/apache/flink/runtime/leaderelection/ZooKeeperLeaderElectionService.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/leaderelection/ZooKeeperLeaderElectionService.java b/flink-runtime/src/main/java/org/apache/flink/runtime/leaderelection/ZooKeeperLeaderElectionService.java
index 920af24..2db1fce 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/leaderelection/ZooKeeperLeaderElectionService.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/leaderelection/ZooKeeperLeaderElectionService.java
@@ -21,6 +21,7 @@ package org.apache.flink.runtime.leaderelection;
 import org.apache.flink.util.ExceptionUtils;
 import org.apache.flink.util.FlinkException;
 import org.apache.flink.util.Preconditions;
+
 import org.apache.curator.framework.CuratorFramework;
 import org.apache.curator.framework.api.UnhandledErrorListener;
 import org.apache.curator.framework.recipes.cache.ChildData;
@@ -53,23 +54,23 @@ public class ZooKeeperLeaderElectionService implements LeaderElectionService, Le
 
 	private final Object lock = new Object();
 
-	/** Client to the ZooKeeper quorum */
+	/** Client to the ZooKeeper quorum. */
 	private final CuratorFramework client;
 
-	/** Curator recipe for leader election */
+	/** Curator recipe for leader election. */
 	private final LeaderLatch leaderLatch;
 
-	/** Curator recipe to watch a given ZooKeeper node for changes */
+	/** Curator recipe to watch a given ZooKeeper node for changes. */
 	private final NodeCache cache;
 
-	/** ZooKeeper path of the node which stores the current leader information */
+	/** ZooKeeper path of the node which stores the current leader information. */
 	private final String leaderPath;
 
 	private UUID issuedLeaderSessionID;
 
 	private volatile UUID confirmedLeaderSessionID;
 
-	/** The leader contender which applies for leadership */
+	/** The leader contender which applies for leadership. */
 	private volatile LeaderContender leaderContender;
 
 	private volatile boolean running;
@@ -164,7 +165,7 @@ public class ZooKeeperLeaderElectionService implements LeaderElectionService, Le
 
 		try {
 			leaderLatch.close();
-		} catch(Exception e) {
+		} catch (Exception e) {
 			exception = ExceptionUtils.firstOrSuppressed(e, exception);
 		}
 
@@ -184,7 +185,7 @@ public class ZooKeeperLeaderElectionService implements LeaderElectionService, Le
 
 		Preconditions.checkNotNull(leaderSessionID);
 
-		if(leaderLatch.hasLeadership()) {
+		if (leaderLatch.hasLeadership()) {
 			// check if this is an old confirmation call
 			synchronized (lock) {
 				if (running) {
@@ -340,14 +341,14 @@ public class ZooKeeperLeaderElectionService implements LeaderElectionService, Le
 
 			boolean dataWritten = false;
 
-			while(!dataWritten && leaderLatch.hasLeadership()) {
+			while (!dataWritten && leaderLatch.hasLeadership()) {
 				Stat stat = client.checkExists().forPath(leaderPath);
 
 				if (stat != null) {
 					long owner = stat.getEphemeralOwner();
 					long sessionID = client.getZookeeperClient().getZooKeeper().getSessionId();
 
-					if(owner == sessionID) {
+					if (owner == sessionID) {
 						try {
 							client.setData().forPath(leaderPath, baos.toByteArray());