Author: aching
Date: Tue Aug 30 16:14:45 2011
New Revision: 1163272
URL: http://svn.apache.org/viewvc?rev=1163272&view=rev
Log:
GIRAPH-17 - Giraph doesn't give up properly after the maximum connect
attempts to ZooKeeper (aching).
Modified:
incubator/giraph/trunk/src/main/java/org/apache/giraph/zk/ZooKeeperManager.java
Modified:
incubator/giraph/trunk/src/main/java/org/apache/giraph/zk/ZooKeeperManager.java
URL:
http://svn.apache.org/viewvc/incubator/giraph/trunk/src/main/java/org/apache/giraph/zk/ZooKeeperManager.java?rev=1163272&r1=1163271&r2=1163272&view=diff
==============================================================================
---
incubator/giraph/trunk/src/main/java/org/apache/giraph/zk/ZooKeeperManager.java
(original)
+++
incubator/giraph/trunk/src/main/java/org/apache/giraph/zk/ZooKeeperManager.java
Tue Aug 30 16:14:45 2011
@@ -476,7 +476,8 @@ public class ZooKeeperManager {
configFile.getName());
}
OutputStreamWriter writer = new FileWriter(configFilePath);
- writer.write("tickTime=" + GiraphJob.DEFAULT_ZOOKEEPER_TICK_TIME +
"\n");
+ writer.write("tickTime=" +
+ GiraphJob.DEFAULT_ZOOKEEPER_TICK_TIME + "\n");
writer.write("dataDir=" + this.zkDir + "\n");
writer.write("clientPort=" + zkBasePort + "\n");
writer.write("maxClientCnxns=" +
@@ -590,10 +591,8 @@ public class ZooKeeperManager {
throw new RuntimeException(e);
}
- /*
- * Once the server is up and running, notify that this server is up
- * and running by dropping a ready stamp.
- */
+ // Once the server is up and running, notify that this server is up
+ // and running by dropping a ready stamp.
int connectAttempts = 0;
final int maxConnectAttempts = 10;
while (connectAttempts < maxConnectAttempts) {
@@ -610,7 +609,10 @@ public class ZooKeeperManager {
new InetSocketAddress(myHostname, zkBasePort);
Socket testServerSock = new Socket();
testServerSock.connect(zkServerAddress, 5000);
- LOG.info("onlineZooKeeperServers: Connected!");
+ if (LOG.isInfoEnabled()) {
+ LOG.info("onlineZooKeeperServers: Connected to " +
+ zkServerAddress + "!");
+ }
break;
} catch (SocketTimeoutException e) {
LOG.warn("onlineZooKeeperServers: Got " +
@@ -631,9 +633,10 @@ public class ZooKeeperManager {
" interrupted - " + e.getMessage());
}
}
- if (connectAttempts == 5) {
+ if (connectAttempts == maxConnectAttempts) {
throw new IllegalStateException(
- "onlineZooKeeperServers: Failed to connect in 5 tries!");
+ "onlineZooKeeperServers: Failed to connect in " +
+ connectAttempts + " tries!");
}
Path myReadyPath = new Path(
serverDirectory, myHostname +