[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-21 Thread Hadoop QA (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16019085#comment-16019085
 ] 

Hadoop QA commented on ZOOKEEPER-2784:
--

+1 overall.  GitHub Pull Request  Build
  

+1 @author.  The patch does not contain any @author tags.

+1 tests included.  The patch appears to include 6 new or modified tests.

+1 javadoc.  The javadoc tool did not generate any warning messages.

+1 javac.  The applied patch does not increase the total number of javac 
compiler warnings.

+1 findbugs.  The patch does not introduce any new Findbugs (version 3.0.1) 
warnings.

+1 release audit.  The applied patch does not increase the total number of 
release audit warnings.

+1 core tests.  The patch passed core unit tests.

+1 contrib tests.  The patch passed contrib unit tests.

Test results: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/726//testReport/
Findbugs warnings: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/726//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
Console output: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/726//console

This message is automatically generated.

> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread Hadoop QA (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16018324#comment-16018324
 ] 

Hadoop QA commented on ZOOKEEPER-2784:
--

-1 overall.  GitHub Pull Request  Build
  

+1 @author.  The patch does not contain any @author tags.

+1 tests included.  The patch appears to include 6 new or modified tests.

+1 javadoc.  The javadoc tool did not generate any warning messages.

+1 javac.  The applied patch does not increase the total number of javac 
compiler warnings.

+1 findbugs.  The patch does not introduce any new Findbugs (version 3.0.1) 
warnings.

+1 release audit.  The applied patch does not increase the total number of 
release audit warnings.

-1 core tests.  The patch failed core unit tests.

+1 contrib tests.  The patch passed contrib unit tests.

Test results: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/725//testReport/
Findbugs warnings: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/725//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
Console output: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/725//console

This message is automatically generated.

> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread Hadoop QA (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16018319#comment-16018319
 ] 

Hadoop QA commented on ZOOKEEPER-2784:
--

-1 overall.  GitHub Pull Request  Build
  

+1 @author.  The patch does not contain any @author tags.

+1 tests included.  The patch appears to include 6 new or modified tests.

+1 javadoc.  The javadoc tool did not generate any warning messages.

+1 javac.  The applied patch does not increase the total number of javac 
compiler warnings.

+1 findbugs.  The patch does not introduce any new Findbugs (version 3.0.1) 
warnings.

+1 release audit.  The applied patch does not increase the total number of 
release audit warnings.

-1 core tests.  The patch failed core unit tests.

+1 contrib tests.  The patch passed contrib unit tests.

Test results: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/724//testReport/
Findbugs warnings: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/724//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
Console output: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/724//console

This message is automatically generated.

> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread Hadoop QA (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16018312#comment-16018312
 ] 

Hadoop QA commented on ZOOKEEPER-2784:
--

-1 overall.  GitHub Pull Request  Build
  

+1 @author.  The patch does not contain any @author tags.

+1 tests included.  The patch appears to include 6 new or modified tests.

+1 javadoc.  The javadoc tool did not generate any warning messages.

+1 javac.  The applied patch does not increase the total number of javac 
compiler warnings.

+1 findbugs.  The patch does not introduce any new Findbugs (version 3.0.1) 
warnings.

+1 release audit.  The applied patch does not increase the total number of 
release audit warnings.

-1 core tests.  The patch failed core unit tests.

+1 contrib tests.  The patch passed contrib unit tests.

Test results: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/723//testReport/
Findbugs warnings: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/723//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
Console output: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/723//console

This message is automatically generated.

> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16018304#comment-16018304
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user asdf2014 commented on the issue:

https://github.com/apache/zookeeper/pull/257
  
I don't understand why `jenkins` reports `UnknownHostException`.

```java
java.net.UnknownHostException: 10.1.1.-113
at 
java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at 
org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:448)
at 
org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:491)
at 
org.apache.zookeeper.server.quorum.QuorumCnxManager.toSend(QuorumCnxManager.java:426)
at 
org.apache.zookeeper.test.CnxManagerTest.testCnxManagerTimeout(CnxManagerTest.java:212)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at 
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at 
org.apache.zookeeper.JUnit4ZKTestRunner$LoggedInvokeMethod.evaluate(JUnit4ZKTestRunner.java:79)
at 
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.rules.TestWatchman$1.evaluate(TestWatchman.java:53)
```


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread Hadoop QA (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16018302#comment-16018302
 ] 

Hadoop QA commented on ZOOKEEPER-2784:
--

-1 overall.  GitHub Pull Request  Build
  

+1 @author.  The patch does not contain any @author tags.

+1 tests included.  The patch appears to include 6 new or modified tests.

+1 javadoc.  The javadoc tool did not generate any warning messages.

+1 javac.  The applied patch does not increase the total number of javac 
compiler warnings.

+1 findbugs.  The patch does not introduce any new Findbugs (version 3.0.1) 
warnings.

+1 release audit.  The applied patch does not increase the total number of 
release audit warnings.

-1 core tests.  The patch failed core unit tests.

+1 contrib tests.  The patch passed contrib unit tests.

Test results: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/722//testReport/
Findbugs warnings: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/722//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
Console output: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/722//console

This message is automatically generated.

> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16018291#comment-16018291
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user asdf2014 commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117600833
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -310,8 +311,8 @@ public boolean initiateConnection(Socket sock, Long 
sid) {
  * possible long value to lose the challenge.
  *
  */
-public void receiveConnection(Socket sock) {
-Long sid = null, protocolVersion = null;
+public void receiveConnection(Socket sock) throws ConfigException {
+Long sid, protocolVersion;
--- End diff --

You are right. I will change it into `long` instead of `Long`.


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16018288#comment-16018288
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user eribeiro commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117600729
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -310,8 +311,8 @@ public boolean initiateConnection(Socket sock, Long 
sid) {
  * possible long value to lose the challenge.
  *
  */
-public void receiveConnection(Socket sock) {
-Long sid = null, protocolVersion = null;
+public void receiveConnection(Socket sock) throws ConfigException {
+Long sid, protocolVersion;
--- End diff --

Yes, integers whose values are between -127 and 128 (inclusive) are cached 
inside Integer object.

Plus, boxing/unboxing in a tight loop (not the case here!) can be a huge 
performance pitfall. For example:

```
for (Integer it = 0; it < 1; ){
   it += 1;
}
```
Used to have abysmal performance numbers due to many auto boxing/unboxing .


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16018284#comment-16018284
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user asdf2014 commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117600609
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -620,6 +625,7 @@ public void run() {
 int numRetries = 0;
 InetSocketAddress addr;
 Socket client = null;
+ConfigException ce = null;
--- End diff --

Okay!


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16018278#comment-16018278
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user eribeiro commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117600572
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -620,6 +625,7 @@ public void run() {
 int numRetries = 0;
 InetSocketAddress addr;
 Socket client = null;
+ConfigException ce = null;
--- End diff --

+1 about `configException` :+1:


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16018276#comment-16018276
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user asdf2014 commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117600503
  
--- Diff: src/java/test/org/apache/zookeeper/test/CnxManagerTest.java ---
@@ -351,15 +351,55 @@ public void testSocketTimeout() throws Exception {
 LOG.info("Election port: " + port);
 Thread.sleep(1000);
 
-Socket sock = new Socket();
-sock.connect(peers.get(1L).electionAddr, 5000);
-long begin = Time.currentElapsedTime();
-// Read without sending data. Verify timeout.
-cnxManager.receiveConnection(sock);
-long end = Time.currentElapsedTime();
-if((end - begin) > ((peer.getSyncLimit() * peer.getTickTime()) + 
500)) Assert.fail("Waited more than necessary");
-cnxManager.halt();
-Assert.assertFalse(cnxManager.listener.isAlive());
+try (Socket sock = new Socket()) {
+sock.connect(peers.get(1L).electionAddr, 5000);
+long begin = Time.currentElapsedTime();
+// Read without sending data. Verify timeout.
+cnxManager.receiveConnection(sock);
+long end = Time.currentElapsedTime();
+if ((end - begin) > ((peer.getSyncLimit() * 
peer.getTickTime()) + 500))
+Assert.fail("Waited more than necessary");
+cnxManager.halt();
+Assert.assertFalse(cnxManager.listener.isAlive());
+}
+}
+
+/*
+ * Test if a duplicate SID appears in the cluster
+ */
+@Test
+public void testSameSID() throws Exception {
+QuorumPeer peer = new QuorumPeer(peers, peerTmpdir[2], 
peerTmpdir[2], peerClientPort[2], 3, 2, 2000, 2, 2);
+QuorumCnxManager cnxManager = new QuorumCnxManager(peer);
+QuorumCnxManager.Listener listener = cnxManager.listener;
+if (listener != null) {
+Thread.UncaughtExceptionHandler handler = new 
Thread.UncaughtExceptionHandler() {
+@Override
+public void uncaughtException(Thread th, Throwable ex) {
+if (ex instanceof RuntimeException) {
+String msg = ex.getMessage();
+LOG.error(msg);
+
Assert.assertEquals("org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException:"
 +
+" Appearing duplicate SID: 2", msg);
+}
+}
+};
+listener.setUncaughtExceptionHandler(handler);
+listener.start();
+} else {
+LOG.error("Null listener when initializing cnx manager");
+}
+try (Socket sock = new Socket()) {
+InetSocketAddress electionAddr = 
peers.get(peer.getId()).electionAddr;
+LOG.info("Creating socket connection, host: {}, port: {}",
+electionAddr.getHostString(), electionAddr.getPort());
+sock.connect(electionAddr, 3);
--- End diff --

I want to fix the `Connection Refused`. I thought the environment `jenkins` 
is not stable...


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16018275#comment-16018275
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user asdf2014 commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117600449
  
--- Diff: src/java/test/org/apache/zookeeper/test/CnxManagerTest.java ---
@@ -351,15 +351,55 @@ public void testSocketTimeout() throws Exception {
 LOG.info("Election port: " + port);
 Thread.sleep(1000);
 
-Socket sock = new Socket();
-sock.connect(peers.get(1L).electionAddr, 5000);
-long begin = Time.currentElapsedTime();
-// Read without sending data. Verify timeout.
-cnxManager.receiveConnection(sock);
-long end = Time.currentElapsedTime();
-if((end - begin) > ((peer.getSyncLimit() * peer.getTickTime()) + 
500)) Assert.fail("Waited more than necessary");
-cnxManager.halt();
-Assert.assertFalse(cnxManager.listener.isAlive());
+try (Socket sock = new Socket()) {
--- End diff --

Okay! I will separate it into a different `jira`.


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16018273#comment-16018273
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user asdf2014 commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117600411
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -677,6 +686,7 @@ public void run() {
 LOG.debug("Error closing server socket", ie);
 }
 }
+if (ce !=null) throw new RuntimeException(ce);
--- End diff --

Thx a lot! I will using `finally` deal with closing `socket`.


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16018270#comment-16018270
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user asdf2014 commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117600362
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -657,9 +663,12 @@ public void run() {
 LOG.error("Error closing server socket", ie);
 } catch (InterruptedException ie) {
 LOG.error("Interrupted while sleeping. " +
-"Ignoring exception", ie);
+"Ignoring exception", ie);
 }
 closeSocket(client);
+} catch (ConfigException e) {
+LOG.error(e.getMessage());
+ce = e;
--- End diff --

Great! I will fix it.


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16018268#comment-16018268
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user asdf2014 commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117600268
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -620,6 +625,7 @@ public void run() {
 int numRetries = 0;
 InetSocketAddress addr;
 Socket client = null;
+ConfigException ce = null;
--- End diff --

Using `configExceptioin`?


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16018267#comment-16018267
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user asdf2014 commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117600247
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -18,6 +18,12 @@
 
 package org.apache.zookeeper.server.quorum;
 
+import org.apache.zookeeper.server.ZooKeeperThread;
--- End diff --

Thank you! I will pay attention. :D


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16018266#comment-16018266
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user asdf2014 commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117600228
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -657,9 +663,12 @@ public void run() {
 LOG.error("Error closing server socket", ie);
 } catch (InterruptedException ie) {
 LOG.error("Interrupted while sleeping. " +
-"Ignoring exception", ie);
+"Ignoring exception", ie);
--- End diff --

Thanks! I will roll it back.


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16018264#comment-16018264
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user asdf2014 commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117600150
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -371,6 +372,10 @@ public void receiveConnection(Socket sock) {
 connectOne(sid);
 }
 
+}else if (sid == self.getId()) {
+closeSocket(sock);
+throw new ConfigException(String.format("Appearing duplicate 
SID: %s", sid));
--- End diff --

Great! I will change it.


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16018263#comment-16018263
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user asdf2014 commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117600142
  
--- Diff: 
src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java ---
@@ -545,6 +545,7 @@ public void testInconsistentPeerType() throws Exception 
{
 defaultedToObserver = true;
 }
 if (warningPresent && defaultedToObserver) {
+LOG.debug("Content from console is: {}", line);
--- End diff --

"QuorumPeerMainTest" has no reason to fail in `jinkens`, so add a logger to 
figure out why. I will remove it.


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16018254#comment-16018254
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user asdf2014 commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117599897
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -371,6 +372,10 @@ public void receiveConnection(Socket sock) {
 connectOne(sid);
 }
 
+}else if (sid == self.getId()) {
--- End diff --

Thanks! I will fix it.


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16018251#comment-16018251
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user asdf2014 commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117599887
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -310,8 +311,8 @@ public boolean initiateConnection(Socket sock, Long 
sid) {
  * possible long value to lose the challenge.
  *
  */
-public void receiveConnection(Socket sock) {
-Long sid = null, protocolVersion = null;
+public void receiveConnection(Socket sock) throws ConfigException {
+Long sid, protocolVersion;
--- End diff --

Yeah, actually it could be a problem. `Long == Long` will call 
`Long.valueof` method, and compare the address of Object. And the 
`Long.valueof` method will create a new `Long` Object when the value of `Long` 
Object more than 127. So, it could return the `false`.
```java
/*
127L == 127L: true
128L == 128L: false
128L equals 128L: true
127 == 127: true
128 == 128: true
 */
public static void main(String... args) {
Long l1 = 127L, l2 = 127L, l3 = 128L, l4 = 128L;
System.out.println("127L == 127L: " + (l1 == l2));
System.out.println("128L == 128L: " + (l3 == l4));
System.out.println("128L equals 128L: " + (l3.equals(l4)));
long ll1 = 127, ll2 = 127, ll3 = 128, ll4 = 128;
System.out.println("127 == 127: " + (ll1 == ll2));
System.out.println("128 == 128: " + (ll3 == ll4));
}
```


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16018003#comment-16018003
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user eribeiro commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117574653
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -371,6 +372,10 @@ public void receiveConnection(Socket sock) {
 connectOne(sid);
 }
 
+}else if (sid == self.getId()) {
+closeSocket(sock);
+throw new ConfigException(String.format("Appearing duplicate 
SID: %s", sid));
--- End diff --

I think this message could be more descriptive or reshaped. English is not 
my 1st language, but what about _"Inconsistent ensemble setup: duplicate SID %s 
found"?_


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16017968#comment-16017968
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user afine commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117565584
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -657,9 +663,12 @@ public void run() {
 LOG.error("Error closing server socket", ie);
 } catch (InterruptedException ie) {
 LOG.error("Interrupted while sleeping. " +
-"Ignoring exception", ie);
+"Ignoring exception", ie);
--- End diff --

nit: whitespace change


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16017970#comment-16017970
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user afine commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117565417
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -620,6 +625,7 @@ public void run() {
 int numRetries = 0;
 InetSocketAddress addr;
 Socket client = null;
+ConfigException ce = null;
--- End diff --

nit: can we use better variable naming?


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16017969#comment-16017969
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user afine commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117565984
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -677,6 +686,7 @@ public void run() {
 LOG.debug("Error closing server socket", ie);
 }
 }
+if (ce !=null) throw new RuntimeException(ce);
--- End diff --

Would it be possible to refactor this so the exception never leaves its 
catch block? Perhaps the logic "in between" can be captured with "finally". 
Then I think we will fix 
https://github.com/apache/zookeeper/pull/257/files#r117407300 as well.


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16017967#comment-16017967
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user afine commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117560586
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -18,6 +18,12 @@
 
 package org.apache.zookeeper.server.quorum;
 
+import org.apache.zookeeper.server.ZooKeeperThread;
--- End diff --

a few unnecessary reordering of imports, these should be kept to a minimum 
to keep the diff clean


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16017971#comment-16017971
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user afine commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117566584
  
--- Diff: src/java/test/org/apache/zookeeper/test/CnxManagerTest.java ---
@@ -351,15 +351,55 @@ public void testSocketTimeout() throws Exception {
 LOG.info("Election port: " + port);
 Thread.sleep(1000);
 
-Socket sock = new Socket();
-sock.connect(peers.get(1L).electionAddr, 5000);
-long begin = Time.currentElapsedTime();
-// Read without sending data. Verify timeout.
-cnxManager.receiveConnection(sock);
-long end = Time.currentElapsedTime();
-if((end - begin) > ((peer.getSyncLimit() * peer.getTickTime()) + 
500)) Assert.fail("Waited more than necessary");
-cnxManager.halt();
-Assert.assertFalse(cnxManager.listener.isAlive());
+try (Socket sock = new Socket()) {
--- End diff --

+1, although please feel free to submit a jira and fix it there!


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16017728#comment-16017728
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user eribeiro commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117441737
  
--- Diff: src/java/test/org/apache/zookeeper/test/CnxManagerTest.java ---
@@ -351,15 +351,55 @@ public void testSocketTimeout() throws Exception {
 LOG.info("Election port: " + port);
 Thread.sleep(1000);
 
-Socket sock = new Socket();
-sock.connect(peers.get(1L).electionAddr, 5000);
-long begin = Time.currentElapsedTime();
-// Read without sending data. Verify timeout.
-cnxManager.receiveConnection(sock);
-long end = Time.currentElapsedTime();
-if((end - begin) > ((peer.getSyncLimit() * peer.getTickTime()) + 
500)) Assert.fail("Waited more than necessary");
-cnxManager.halt();
-Assert.assertFalse(cnxManager.listener.isAlive());
+try (Socket sock = new Socket()) {
--- End diff --

It looks like the reason for changing those lines was to include a ARM 
block, right?

I understand the motivation and have to refrain myself from doing the same 
a couple of times, but this kind of refactoring would be goal of a separate 
issue as **it is not related to the bug/feature of this issue** (aka _don't fix 
if it's not broken_).

So, it revert it to the original one, please. :)



> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16017729#comment-16017729
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user eribeiro commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117530984
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -677,6 +686,7 @@ public void run() {
 LOG.debug("Error closing server socket", ie);
 }
 }
+if (ce !=null) throw new RuntimeException(ce);
--- End diff --

Okay, I am still unsure if throwing a Runtime exception is the best 
approach here.


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16017730#comment-16017730
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user eribeiro commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117527100
  
--- Diff: src/java/test/org/apache/zookeeper/test/CnxManagerTest.java ---
@@ -351,15 +351,55 @@ public void testSocketTimeout() throws Exception {
 LOG.info("Election port: " + port);
 Thread.sleep(1000);
 
-Socket sock = new Socket();
-sock.connect(peers.get(1L).electionAddr, 5000);
-long begin = Time.currentElapsedTime();
-// Read without sending data. Verify timeout.
-cnxManager.receiveConnection(sock);
-long end = Time.currentElapsedTime();
-if((end - begin) > ((peer.getSyncLimit() * peer.getTickTime()) + 
500)) Assert.fail("Waited more than necessary");
-cnxManager.halt();
-Assert.assertFalse(cnxManager.listener.isAlive());
+try (Socket sock = new Socket()) {
+sock.connect(peers.get(1L).electionAddr, 5000);
+long begin = Time.currentElapsedTime();
+// Read without sending data. Verify timeout.
+cnxManager.receiveConnection(sock);
+long end = Time.currentElapsedTime();
+if ((end - begin) > ((peer.getSyncLimit() * 
peer.getTickTime()) + 500))
+Assert.fail("Waited more than necessary");
+cnxManager.halt();
+Assert.assertFalse(cnxManager.listener.isAlive());
+}
+}
+
+/*
+ * Test if a duplicate SID appears in the cluster
+ */
+@Test
+public void testSameSID() throws Exception {
+QuorumPeer peer = new QuorumPeer(peers, peerTmpdir[2], 
peerTmpdir[2], peerClientPort[2], 3, 2, 2000, 2, 2);
+QuorumCnxManager cnxManager = new QuorumCnxManager(peer);
+QuorumCnxManager.Listener listener = cnxManager.listener;
+if (listener != null) {
+Thread.UncaughtExceptionHandler handler = new 
Thread.UncaughtExceptionHandler() {
+@Override
+public void uncaughtException(Thread th, Throwable ex) {
+if (ex instanceof RuntimeException) {
+String msg = ex.getMessage();
+LOG.error(msg);
+
Assert.assertEquals("org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException:"
 +
+" Appearing duplicate SID: 2", msg);
+}
+}
+};
+listener.setUncaughtExceptionHandler(handler);
+listener.start();
+} else {
+LOG.error("Null listener when initializing cnx manager");
+}
+try (Socket sock = new Socket()) {
+InetSocketAddress electionAddr = 
peers.get(peer.getId()).electionAddr;
+LOG.info("Creating socket connection, host: {}, port: {}",
+electionAddr.getHostString(), electionAddr.getPort());
+sock.connect(electionAddr, 3);
--- End diff --

The timeout here is way to big (3 ms) with relation to the other tests 
(5000 ms).


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16017731#comment-16017731
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user eribeiro commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117407300
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -657,9 +663,12 @@ public void run() {
 LOG.error("Error closing server socket", ie);
 } catch (InterruptedException ie) {
 LOG.error("Interrupted while sleeping. " +
-"Ignoring exception", ie);
+"Ignoring exception", ie);
 }
 closeSocket(client);
+} catch (ConfigException e) {
+LOG.error(e.getMessage());
+ce = e;
--- End diff --

:+1: BUT you need to call `closeSocket(client);` here too. See line 668. ;) 
It is the ServerSocket and Socket we need to close in case of error. I know we 
close the socket previously before throwing the exception, but `Socket#close()` 
is idempotent so, I would advise to put it here too. In fact, we could remove 
line 668 and add a `finally` block with the  `closeSocket(client);` after line 
672.

**Most important!** The latest change doesn't break the while loop so it 
only leave after reaching the maximum number of retries or shutdown is called 
(I bet the first). We should include a `break;` at line 672. ;)



> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16017727#comment-16017727
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user eribeiro commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117528337
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -310,8 +311,8 @@ public boolean initiateConnection(Socket sock, Long 
sid) {
  * possible long value to lose the challenge.
  *
  */
-public void receiveConnection(Socket sock) {
-Long sid = null, protocolVersion = null;
+public void receiveConnection(Socket sock) throws ConfigException {
+Long sid, protocolVersion;
--- End diff --

As we removed the extraneous `null` here we could also use the primitive 
long type, right? I don't see any gain of using boxed types here. I see a lot 
of boxing/unboxing down in this method, so it could be simply `int sid, 
protocolVersion;` (this slightly falls into "the don't fix if..." adage, but we 
can ignore this for once ;) ).


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16017725#comment-16017725
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user eribeiro commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117529199
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -371,6 +372,10 @@ public void receiveConnection(Socket sock) {
 connectOne(sid);
 }
 
+}else if (sid == self.getId()) {
--- End diff --

nit: space between `{` and `else`


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-19 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16017726#comment-16017726
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user eribeiro commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117529736
  
--- Diff: 
src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java ---
@@ -545,6 +545,7 @@ public void testInconsistentPeerType() throws Exception 
{
 defaultedToObserver = true;
 }
 if (warningPresent && defaultedToObserver) {
+LOG.debug("Content from console is: {}", line);
--- End diff --

Ugh?! What is the purpose of this for the issue at hand?


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-18 Thread Hadoop QA (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16016924#comment-16016924
 ] 

Hadoop QA commented on ZOOKEEPER-2784:
--

+1 overall.  GitHub Pull Request  Build
  

+1 @author.  The patch does not contain any @author tags.

+1 tests included.  The patch appears to include 6 new or modified tests.

+1 javadoc.  The javadoc tool did not generate any warning messages.

+1 javac.  The applied patch does not increase the total number of javac 
compiler warnings.

+1 findbugs.  The patch does not introduce any new Findbugs (version 3.0.1) 
warnings.

+1 release audit.  The applied patch does not increase the total number of 
release audit warnings.

+1 core tests.  The patch passed core unit tests.

+1 contrib tests.  The patch passed contrib unit tests.

Test results: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/718//testReport/
Findbugs warnings: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/718//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
Console output: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/718//console

This message is automatically generated.

> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-18 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16016915#comment-16016915
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user asdf2014 commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117406260
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -660,6 +665,9 @@ public void run() {
 "Ignoring exception", ie);
 }
 closeSocket(client);
+} catch (ConfigException ce) {
+LOG.error(ce.getMessage());
+throw new RuntimeException(ce);
--- End diff --

You are right. Throwing 'RuntimeException' does skip the closing 
`ServerSocket` part, so I moved it to the end of the` run` method.


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-18 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16016899#comment-16016899
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user eribeiro commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117403350
  
--- Diff: 
src/java/main/org/apache/zookeeper/server/quorum/QuorumCnxManager.java ---
@@ -660,6 +665,9 @@ public void run() {
 "Ignoring exception", ie);
 }
 closeSocket(client);
+} catch (ConfigException ce) {
+LOG.error(ce.getMessage());
+throw new RuntimeException(ce);
--- End diff --

Don't we have to call `closeSocket(client)` here before throwing the 
`RuntimeException`? Relying on OS/JVM to close a socket can be too much 
optimistic and leak resources. If I am right (please double check) then line 
667 can be moved to a finally block just below this catch clause.

Also, as the program flow is interrupted if a `ConfigException` is thrown 
lines 679-687 wouldn't be called and then `ServerSocket` also is not properly 
closed, right?

PS: I am not sure, would have to look carefully later and don't have time 
now, so excuse me if I am misunderstood it.



> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-18 Thread Hadoop QA (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16016883#comment-16016883
 ] 

Hadoop QA commented on ZOOKEEPER-2784:
--

+1 overall.  GitHub Pull Request  Build
  

+1 @author.  The patch does not contain any @author tags.

+1 tests included.  The patch appears to include 6 new or modified tests.

+1 javadoc.  The javadoc tool did not generate any warning messages.

+1 javac.  The applied patch does not increase the total number of javac 
compiler warnings.

+1 findbugs.  The patch does not introduce any new Findbugs (version 3.0.1) 
warnings.

+1 release audit.  The applied patch does not increase the total number of 
release audit warnings.

+1 core tests.  The patch passed core unit tests.

+1 contrib tests.  The patch passed contrib unit tests.

Test results: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/717//testReport/
Findbugs warnings: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/717//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
Console output: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/717//console

This message is automatically generated.

> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-18 Thread Hadoop QA (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16016879#comment-16016879
 ] 

Hadoop QA commented on ZOOKEEPER-2784:
--

+1 overall.  GitHub Pull Request  Build
  

+1 @author.  The patch does not contain any @author tags.

+1 tests included.  The patch appears to include 6 new or modified tests.

+1 javadoc.  The javadoc tool did not generate any warning messages.

+1 javac.  The applied patch does not increase the total number of javac 
compiler warnings.

+1 findbugs.  The patch does not introduce any new Findbugs (version 3.0.1) 
warnings.

+1 release audit.  The applied patch does not increase the total number of 
release audit warnings.

+1 core tests.  The patch passed core unit tests.

+1 contrib tests.  The patch passed contrib unit tests.

Test results: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/716//testReport/
Findbugs warnings: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/716//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
Console output: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/716//console

This message is automatically generated.

> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-18 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16016869#comment-16016869
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user asdf2014 commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117400479
  
--- Diff: src/java/test/org/apache/zookeeper/test/CnxManagerTest.java ---
@@ -18,36 +18,32 @@
 
 package org.apache.zookeeper.test;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.net.InetSocketAddress;
-import java.nio.ByteBuffer;
-import java.nio.channels.SocketChannel;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-import java.net.Socket;
-
-import org.apache.zookeeper.common.Time;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.zookeeper.PortAssignment;
 import org.apache.zookeeper.ZKTestCase;
+import org.apache.zookeeper.common.Time;
 import org.apache.zookeeper.server.quorum.QuorumCnxManager;
-import org.apache.zookeeper.server.quorum.QuorumCnxManager.Message;
 import org.apache.zookeeper.server.quorum.QuorumCnxManager.InitialMessage;
+import org.apache.zookeeper.server.quorum.QuorumCnxManager.Message;
 import org.apache.zookeeper.server.quorum.QuorumPeer;
 import org.apache.zookeeper.server.quorum.QuorumPeer.LearnerType;
 import org.apache.zookeeper.server.quorum.QuorumPeer.QuorumServer;
 import org.apache.zookeeper.server.quorum.QuorumPeer.ServerState;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.*;
--- End diff --

I see. I will roll it back.


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-18 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16016867#comment-16016867
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user eribeiro commented on a diff in the pull request:

https://github.com/apache/zookeeper/pull/257#discussion_r117400348
  
--- Diff: src/java/test/org/apache/zookeeper/test/CnxManagerTest.java ---
@@ -18,36 +18,32 @@
 
 package org.apache.zookeeper.test;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.net.InetSocketAddress;
-import java.nio.ByteBuffer;
-import java.nio.channels.SocketChannel;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Random;
-import java.util.concurrent.TimeUnit;
-import java.net.Socket;
-
-import org.apache.zookeeper.common.Time;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.zookeeper.PortAssignment;
 import org.apache.zookeeper.ZKTestCase;
+import org.apache.zookeeper.common.Time;
 import org.apache.zookeeper.server.quorum.QuorumCnxManager;
-import org.apache.zookeeper.server.quorum.QuorumCnxManager.Message;
 import org.apache.zookeeper.server.quorum.QuorumCnxManager.InitialMessage;
+import org.apache.zookeeper.server.quorum.QuorumCnxManager.Message;
 import org.apache.zookeeper.server.quorum.QuorumPeer;
 import org.apache.zookeeper.server.quorum.QuorumPeer.LearnerType;
 import org.apache.zookeeper.server.quorum.QuorumPeer.QuorumServer;
 import org.apache.zookeeper.server.quorum.QuorumPeer.ServerState;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.*;
--- End diff --

@asdf2014 FYI, ZK codebase gives preference to explicit imports instead of 
using wildcards.


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-18 Thread Hadoop QA (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16016854#comment-16016854
 ] 

Hadoop QA commented on ZOOKEEPER-2784:
--

-1 overall.  GitHub Pull Request  Build
  

+1 @author.  The patch does not contain any @author tags.

+1 tests included.  The patch appears to include 3 new or modified tests.

+1 javadoc.  The javadoc tool did not generate any warning messages.

+1 javac.  The applied patch does not increase the total number of javac 
compiler warnings.

+1 findbugs.  The patch does not introduce any new Findbugs (version 3.0.1) 
warnings.

+1 release audit.  The applied patch does not increase the total number of 
release audit warnings.

-1 core tests.  The patch failed core unit tests.

+1 contrib tests.  The patch passed contrib unit tests.

Test results: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/715//testReport/
Findbugs warnings: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/715//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
Console output: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/715//console

This message is automatically generated.

> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-18 Thread Hadoop QA (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16016825#comment-16016825
 ] 

Hadoop QA commented on ZOOKEEPER-2784:
--

-1 overall.  GitHub Pull Request  Build
  

+1 @author.  The patch does not contain any @author tags.

+1 tests included.  The patch appears to include 3 new or modified tests.

+1 javadoc.  The javadoc tool did not generate any warning messages.

+1 javac.  The applied patch does not increase the total number of javac 
compiler warnings.

+1 findbugs.  The patch does not introduce any new Findbugs (version 3.0.1) 
warnings.

+1 release audit.  The applied patch does not increase the total number of 
release audit warnings.

-1 core tests.  The patch failed core unit tests.

+1 contrib tests.  The patch passed contrib unit tests.

Test results: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/713//testReport/
Findbugs warnings: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/713//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
Console output: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/713//console

This message is automatically generated.

> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-18 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16016660#comment-16016660
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user hanm commented on the issue:

https://github.com/apache/zookeeper/pull/257
  
@asdf2014 : There are lots of formatting changes in this patch, which makes 
review harder.  Can you please update the patch to avoid those formatting 
changes? See [How To 
Contribute](https://cwiki.apache.org/confluence/display/ZOOKEEPER/HowToContribute):

## Please don't do in pull request:
reformat code unrelated to the bug being fixed: formatting changes should 
be separate patches/commits.


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.6.0
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-18 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16015514#comment-16015514
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user asdf2014 commented on the issue:

https://github.com/apache/zookeeper/pull/257
  
Finally, it works :smile:
```bash
 [exec] [junit] 2017-05-18 09:29:00,770 [myid:] - INFO  
[main:ZKTestCase$1@58] - STARTING testSameSID
 [exec] [junit] 2017-05-18 09:29:00,770 [myid:] - INFO  
[main:PortAssignment@85] - Assigned port 24753 from range 24686 - 27378.
 [exec] [junit] 2017-05-18 09:29:00,770 [myid:] - INFO  
[main:PortAssignment@85] - Assigned port 24754 from range 24686 - 27378.
 [exec] [junit] 2017-05-18 09:29:00,771 [myid:] - INFO  
[main:PortAssignment@85] - Assigned port 24755 from range 24686 - 27378.
 [exec] [junit] 2017-05-18 09:29:00,771 [myid:] - INFO  
[main:PortAssignment@85] - Assigned port 24756 from range 24686 - 27378.
 [exec] [junit] 2017-05-18 09:29:00,771 [myid:] - INFO  
[main:PortAssignment@85] - Assigned port 24757 from range 24686 - 27378.
 [exec] [junit] 2017-05-18 09:29:00,772 [myid:] - INFO  
[main:PortAssignment@85] - Assigned port 24758 from range 24686 - 27378.
 [exec] [junit] 2017-05-18 09:29:00,772 [myid:] - INFO  
[main:PortAssignment@85] - Assigned port 24759 from range 24686 - 27378.
 [exec] [junit] 2017-05-18 09:29:00,772 [myid:] - INFO  
[main:PortAssignment@85] - Assigned port 24760 from range 24686 - 27378.
 [exec] [junit] 2017-05-18 09:29:00,773 [myid:] - INFO  
[main:PortAssignment@85] - Assigned port 24761 from range 24686 - 27378.
 [exec] [junit] 2017-05-18 09:29:00,773 [myid:] - INFO  
[main:JUnit4ZKTestRunner$LoggedInvokeMethod@77] - RUNNING TEST METHOD 
testSameSID
 [exec] [junit] 2017-05-18 09:29:00,773 [myid:] - INFO  
[main:ServerCnxnFactory@134] - Using 
org.apache.zookeeper.server.NIOServerCnxnFactory as server connection factory
 [exec] [junit] 2017-05-18 09:29:00,773 [myid:] - INFO  
[main:NIOServerCnxnFactory@673] - Configuring NIO connection handler with 10s 
sessionless connection timeout, 3 selector thread(s), 48 worker threads, and 64 
kB direct buffers.
 [exec] [junit] 2017-05-18 09:29:00,774 [myid:] - INFO  
[main:NIOServerCnxnFactory@686] - binding to port /127.0.0.1:24760
 [exec] [junit] 2017-05-18 09:29:00,775 [myid:] - INFO  
[main:CnxManagerTest@392] - Creating socket connection, host: 127.0.0.1, port: 
24761
 [exec] [junit] 2017-05-18 09:29:00,775 [myid:] - INFO  
[QuorumPeerListener:QuorumCnxManager$Listener@636] - My election bind port: 
/127.0.0.1:24761
 [exec] [junit] 2017-05-18 09:29:00,775 [myid:] - INFO  
[/127.0.0.1:24761:QuorumCnxManager$Listener@642] - Received connection request 
/127.0.0.1:54430
 [exec] [junit] 2017-05-18 09:29:00,775 [myid:] - WARN  
[main:QuorumCnxManager@342] - Exception reading or writing challenge: 
java.io.EOFException
 [exec] [junit] 2017-05-18 09:29:00,776 [myid:] - ERROR 
[/127.0.0.1:24761:QuorumCnxManager$Listener@664] - Appearing duplicate SID: 2
```


> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.5.4
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-18 Thread Hadoop QA (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16015501#comment-16015501
 ] 

Hadoop QA commented on ZOOKEEPER-2784:
--

+1 overall.  GitHub Pull Request  Build
  

+1 @author.  The patch does not contain any @author tags.

+1 tests included.  The patch appears to include 3 new or modified tests.

+1 javadoc.  The javadoc tool did not generate any warning messages.

+1 javac.  The applied patch does not increase the total number of javac 
compiler warnings.

+1 findbugs.  The patch does not introduce any new Findbugs (version 3.0.1) 
warnings.

+1 release audit.  The applied patch does not increase the total number of 
release audit warnings.

+1 core tests.  The patch passed core unit tests.

+1 contrib tests.  The patch passed contrib unit tests.

Test results: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/705//testReport/
Findbugs warnings: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/705//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
Console output: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/705//console

This message is automatically generated.

> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.5.4
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-18 Thread Hadoop QA (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16015420#comment-16015420
 ] 

Hadoop QA commented on ZOOKEEPER-2784:
--

-1 overall.  GitHub Pull Request  Build
  

+1 @author.  The patch does not contain any @author tags.

+1 tests included.  The patch appears to include 3 new or modified tests.

+1 javadoc.  The javadoc tool did not generate any warning messages.

+1 javac.  The applied patch does not increase the total number of javac 
compiler warnings.

+1 findbugs.  The patch does not introduce any new Findbugs (version 3.0.1) 
warnings.

+1 release audit.  The applied patch does not increase the total number of 
release audit warnings.

-1 core tests.  The patch failed core unit tests.

+1 contrib tests.  The patch passed contrib unit tests.

Test results: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/704//testReport/
Findbugs warnings: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/704//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
Console output: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/704//console

This message is automatically generated.

> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.5.4
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-18 Thread Hadoop QA (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16015338#comment-16015338
 ] 

Hadoop QA commented on ZOOKEEPER-2784:
--

-1 overall.  GitHub Pull Request  Build
  

+1 @author.  The patch does not contain any @author tags.

+1 tests included.  The patch appears to include 3 new or modified tests.

+1 javadoc.  The javadoc tool did not generate any warning messages.

+1 javac.  The applied patch does not increase the total number of javac 
compiler warnings.

+1 findbugs.  The patch does not introduce any new Findbugs (version 3.0.1) 
warnings.

+1 release audit.  The applied patch does not increase the total number of 
release audit warnings.

-1 core tests.  The patch failed core unit tests.

+1 contrib tests.  The patch passed contrib unit tests.

Test results: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/703//testReport/
Findbugs warnings: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/703//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
Console output: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/703//console

This message is automatically generated.

> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.5.4
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-18 Thread Hadoop QA (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16015300#comment-16015300
 ] 

Hadoop QA commented on ZOOKEEPER-2784:
--

-1 overall.  GitHub Pull Request  Build
  

+1 @author.  The patch does not contain any @author tags.

+1 tests included.  The patch appears to include 3 new or modified tests.

+1 javadoc.  The javadoc tool did not generate any warning messages.

+1 javac.  The applied patch does not increase the total number of javac 
compiler warnings.

+1 findbugs.  The patch does not introduce any new Findbugs (version 3.0.1) 
warnings.

+1 release audit.  The applied patch does not increase the total number of 
release audit warnings.

-1 core tests.  The patch failed core unit tests.

+1 contrib tests.  The patch passed contrib unit tests.

Test results: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/702//testReport/
Findbugs warnings: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/702//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
Console output: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/702//console

This message is automatically generated.

> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.5.4
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-17 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16015241#comment-16015241
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

Github user asdf2014 commented on the issue:

https://github.com/apache/zookeeper/pull/257
  
It's total fine in my local IDE...

![image](https://cloud.githubusercontent.com/assets/8108788/26188075/ba301912-3bcf-11e7-92c8-79497eea1a9b.png)



> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.5.4
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-17 Thread Hadoop QA (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16015177#comment-16015177
 ] 

Hadoop QA commented on ZOOKEEPER-2784:
--

-1 overall.  GitHub Pull Request  Build
  

+1 @author.  The patch does not contain any @author tags.

+1 tests included.  The patch appears to include 3 new or modified tests.

+1 javadoc.  The javadoc tool did not generate any warning messages.

+1 javac.  The applied patch does not increase the total number of javac 
compiler warnings.

+1 findbugs.  The patch does not introduce any new Findbugs (version 3.0.1) 
warnings.

+1 release audit.  The applied patch does not increase the total number of 
release audit warnings.

-1 core tests.  The patch failed core unit tests.

+1 contrib tests.  The patch passed contrib unit tests.

Test results: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/701//testReport/
Findbugs warnings: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/701//artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
Console output: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-github-pr-build/701//console

This message is automatically generated.

> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.5.4
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ZOOKEEPER-2784) Add some limitations on code level for `SID` to avoid configuration problem

2017-05-17 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16015156#comment-16015156
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2784:
---

GitHub user asdf2014 opened a pull request:

https://github.com/apache/zookeeper/pull/257

ZOOKEEPER-2784: Add same `sid` config problem check

Add some limitations on code level for `SID` to avoid configuration problem

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/asdf2014/zookeeper quorum_sid

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/zookeeper/pull/257.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #257


commit 4447631b3d2b7cd58f0fd4d92923ff87482330a9
Author: asdf2014 <1571805...@qq.com>
Date:   2017-05-18T03:47:00Z

ZOOKEEPER-2784: Add same `sid` config problem check




> Add some limitations on code level for `SID` to avoid configuration problem
> ---
>
> Key: ZOOKEEPER-2784
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2784
> Project: ZooKeeper
>  Issue Type: Improvement
>  Components: quorum
>Affects Versions: 3.5.2
>Reporter: Benedict Jin
> Fix For: 3.5.4
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> As so far, `QuorumCnxManager#receiveConnection` cannot find out the same 
> `SID` problem, then the Zookeeper cluster will start successfully. But the 
> cluster is not health, and it will throw some problem like `not 
> synchronized`. So, i thought we should add some limitations on code level for 
> `SID` to find those configuration problem more early.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)