helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zzh...@apache.org
Subject git commit: HELIX-41: fix intermittent test failures
Date Wed, 06 Feb 2013 23:47:55 GMT
Updated Branches:
  refs/heads/master 575f916e6 -> 88cd21432


HELIX-41: fix intermittent test failures


Project: http://git-wip-us.apache.org/repos/asf/incubator-helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-helix/commit/88cd2143
Tree: http://git-wip-us.apache.org/repos/asf/incubator-helix/tree/88cd2143
Diff: http://git-wip-us.apache.org/repos/asf/incubator-helix/diff/88cd2143

Branch: refs/heads/master
Commit: 88cd2143251e9970446ed631325f5e593be3b46c
Parents: 575f916
Author: zzhang <zzhang5@uci.edu>
Authored: Wed Feb 6 15:47:45 2013 -0800
Committer: zzhang <zzhang5@uci.edu>
Committed: Wed Feb 6 15:47:45 2013 -0800

----------------------------------------------------------------------
 .../handling/HelixStateTransitionHandler.java      |    6 -
 .../test/java/org/apache/helix/ZkTestHelper.java   |   77 +++++++++------
 .../TestAddNodeAfterControllerStart.java           |   18 ++--
 3 files changed, 55 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/88cd2143/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixStateTransitionHandler.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixStateTransitionHandler.java
b/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixStateTransitionHandler.java
index 20b2ff1..3c952b9 100644
--- a/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixStateTransitionHandler.java
+++ b/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixStateTransitionHandler.java
@@ -270,11 +270,9 @@ public class HelixStateTransitionHandler extends MessageHandler
                                 accessor);
       message.setExecuteStartTimeStamp(new Date().getTime());
 
-      // Exception exception = null;
       try
       {
     	preHandleMessage();
-        // prepareMessageExecution(manager, message);
         invoke(accessor, context, taskResult, message);
       }
       catch (HelixStateMismatchException e)
@@ -284,8 +282,6 @@ public class HelixStateTransitionHandler extends MessageHandler
         taskResult.setSuccess(false);
         taskResult.setMessage(e.toString());
         taskResult.setException(e);
-        // exception = e;
-        // return taskResult;
       }
       catch (Exception e)
       {
@@ -306,9 +302,7 @@ public class HelixStateTransitionHandler extends MessageHandler
         taskResult.setMessage(e.toString());
         taskResult.setException(e);
         taskResult.setInterrupted(e instanceof InterruptedException);
-        // exception = e;
       }
-//      postExecutionMessage(manager, message, context, taskResult, exception);
       
       // add task result to context for postHandling
       context.add(MapKey.HELIX_TASK_RESULT.toString(), taskResult);

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/88cd2143/helix-core/src/test/java/org/apache/helix/ZkTestHelper.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/ZkTestHelper.java b/helix-core/src/test/java/org/apache/helix/ZkTestHelper.java
index 34d391b..9f074e9 100644
--- a/helix-core/src/test/java/org/apache/helix/ZkTestHelper.java
+++ b/helix-core/src/test/java/org/apache/helix/ZkTestHelper.java
@@ -262,40 +262,55 @@ public class ZkTestHelper
    */
   public static Map<String, Set<String>> getListenersByZkPath(String zkAddr)
throws Exception
   {
-    int count = 0;
     String splits[] = zkAddr.split(":");
-    Socket sock = new Socket(splits[0], Integer.parseInt(splits[1]));
-    PrintWriter out = new PrintWriter(sock.getOutputStream(), true);
-    BufferedReader in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
-
-    out.println("wchp");
-
     Map<String, Set<String>> listenerMap = new TreeMap<String, Set<String>>();
-    String lastPath = null;
-    String line = in.readLine();
-    while (line != null)
-    {
-    	line = line.trim();
-    	
-    	if (line.startsWith("/")) {
-    		lastPath = line;
-    		if (!listenerMap.containsKey(lastPath)) {
-    			listenerMap.put(lastPath, new TreeSet<String>());
-    		}
-    	} else if (line.startsWith("0x")) {
-    		if (lastPath != null && listenerMap.containsKey(lastPath) ) {
-    			listenerMap.get(lastPath).add(line);
-    		} else
-    		{
-    			LOG.error("Not path associated with listener sessionId: " + line + ", lastPath: "
+ lastPath);
-    		}
-    	} else
-    	{
-//    		LOG.error("unrecognized line: " + line);
-    	}
-      line = in.readLine();
+    Socket sock = null;
+    int retry = 5;
+    
+    while (retry > 0) {
+      try {
+        sock = new Socket(splits[0], Integer.parseInt(splits[1]));
+        PrintWriter out = new PrintWriter(sock.getOutputStream(), true);
+        BufferedReader in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
+    
+        out.println("wchp");
+    
+        listenerMap.clear();
+        String lastPath = null;
+        String line = in.readLine();
+        while (line != null)
+        {
+        	line = line.trim();
+        	
+        	if (line.startsWith("/")) {
+        		lastPath = line;
+        		if (!listenerMap.containsKey(lastPath)) {
+        			listenerMap.put(lastPath, new TreeSet<String>());
+        		}
+        	} else if (line.startsWith("0x")) {
+        		if (lastPath != null && listenerMap.containsKey(lastPath) ) {
+        			listenerMap.get(lastPath).add(line);
+        		} else
+        		{
+        			LOG.error("Not path associated with listener sessionId: " + line + ", lastPath:
" + lastPath);
+        		}
+        	} else
+        	{
+    //    		LOG.error("unrecognized line: " + line);
+        	}
+          line = in.readLine();
+        }
+        break;
+      } catch (Exception e) {
+    	  // sometimes in test, we see connection-reset exceptions when in.readLine()
+    	  // so add this retry logic
+    	  retry--;
+      } finally
+      {
+    	if (sock != null)
+    		sock.close();
+      }
     }
-    sock.close();
     return listenerMap;
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/88cd2143/helix-core/src/test/java/org/apache/helix/integration/TestAddNodeAfterControllerStart.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestAddNodeAfterControllerStart.java
b/helix-core/src/test/java/org/apache/helix/integration/TestAddNodeAfterControllerStart.java
index 88cc82c..9898d55 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestAddNodeAfterControllerStart.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestAddNodeAfterControllerStart.java
@@ -104,11 +104,11 @@ public class TestAddNodeAfterControllerStart extends ZkIntegrationTestBase
     Assert.assertTrue(result);
 
     // clean up
-    controller.disconnect();
-    for (int i = 0; i < nodeNr; i++)
-    {
-      participants[i].syncStop();
-    }
+//    controller.disconnect();
+//    for (int i = 0; i < nodeNr; i++)
+//    {
+//      participants[i].syncStop();
+//    }
 
     System.out.println("END " + clusterName + " at "
         + new Date(System.currentTimeMillis()));
@@ -199,10 +199,10 @@ public class TestAddNodeAfterControllerStart extends ZkIntegrationTestBase
     Assert.assertEquals(numberOfListeners, 2);  // 1 of participant, and 1 of controller
 
     // clean up
-    for (int i = 0; i < nodeNr; i++)
-    {
-      participants[i].syncStop();
-    }
+//    for (int i = 0; i < nodeNr; i++)
+//    {
+//      participants[i].syncStop();
+//    }
 
     System.out.println("END " + clusterName + " at "
         + new Date(System.currentTimeMillis()));


Mime
View raw message