Author: kwright
Date: Tue Nov 26 10:08:55 2013
New Revision: 1545594

URL: http://svn.apache.org/r1545594
Log:
Debug

Modified:
    
manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/BaseLockManager.java
    
manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperConnection.java
    
manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperLockManager.java

Modified: 
manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/BaseLockManager.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/BaseLockManager.java?rev=1545594&r1=1545593&r2=1545594&view=diff
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/BaseLockManager.java
 (original)
+++ 
manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/BaseLockManager.java
 Tue Nov 26 10:08:55 2013
@@ -164,6 +164,7 @@ public class BaseLockManager implements 
           clearGlobalFlag(makeRegisteredServiceFlagName(serviceType, x));
           writeServiceName(resourceName, null);
         }
+        foundService = false;
       }
 
       // Now, register (if needed)

Modified: 
manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperConnection.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperConnection.java?rev=1545594&r1=1545593&r2=1545594&view=diff
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperConnection.java
 (original)
+++ 
manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperConnection.java
 Tue Nov 26 10:08:55 2013
@@ -42,6 +42,8 @@ public class ZooKeeperConnection
   private static final String NONEXWRITE_PREFIX = "nonexwrite-";
   private static final String WRITE_PREFIX = "write-";
 
+  private static final String CHILD_PREFIX = "child-";
+  
   // Our zookeeper client
   protected ZooKeeper zookeeper = null;
   protected ZooKeeperWatcher zookeeperWatcher = null;
@@ -118,12 +120,21 @@ public class ZooKeeperConnection
   /** Get the relative paths of all node's children.  If the node does not 
exist,
   * return an empty list.
   */
-  public List<String> getNodeChildren(String nodePath)
+  public List<String> getChildren(String nodePath)
     throws ManifoldCFException, InterruptedException
   {
     try
     {
-      return zookeeper.getChildren(nodePath,false);
+      //System.out.println("Children of '"+nodePath+"':");
+      List<String> children = zookeeper.getChildren(nodePath,false);
+      List<String> rval = new ArrayList<String>();
+      for (String child : children)
+      {
+        //System.out.println(" '"+child+"'");
+        if (child.startsWith(CHILD_PREFIX))
+          rval.add(child.substring(CHILD_PREFIX.length()));
+      }
+      return rval;
     }
     catch (KeeperException.NoNodeException e)
     {
@@ -142,11 +153,13 @@ public class ZooKeeperConnection
   {
     try
     {
+      //System.out.println("Creating child '"+childName+"' of nodepath 
'"+nodePath+"'");
       while (true)
       {
         try
         {
-          zookeeper.create(nodePath + "/" + childName, new byte[0], 
ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
+          zookeeper.create(nodePath + "/" + CHILD_PREFIX + childName, new 
byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
+          break;
         }
         catch (KeeperException.NoNodeException e)
         {
@@ -159,6 +172,7 @@ public class ZooKeeperConnection
           }
         }
       }
+      System.out.println("...done");
     }
     catch (KeeperException e)
     {
@@ -173,7 +187,9 @@ public class ZooKeeperConnection
   {
     try
     {
-      zookeeper.delete(nodePath + "/" + childName, -1);
+      //System.out.println("Deleting child '"+childName+"' of nodePath 
'"+nodePath+"'");
+      zookeeper.delete(nodePath + "/" + CHILD_PREFIX + childName, -1);
+      //System.out.println("...done");
     }
     catch (KeeperException e)
     {

Modified: 
manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperLockManager.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperLockManager.java?rev=1545594&r1=1545593&r2=1545594&view=diff
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperLockManager.java
 (original)
+++ 
manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/ZooKeeperLockManager.java
 Tue Nov 26 10:08:55 2013
@@ -122,7 +122,7 @@ public class ZooKeeperLockManager extend
           // We need to find out whether (a) our service is already 
registered; (b) how many registered services there are;
           // (c) whether there are other active services.  But no changes will 
be made at this time.
           String registrationNodePath = 
buildServiceTypeRegistrationPath(serviceType);
-          List<String> children = 
connection.getNodeChildren(registrationNodePath);
+          List<String> children = connection.getChildren(registrationNodePath);
           boolean foundService = false;
           boolean foundActiveService = false;
           for (String registeredServiceName : children)
@@ -156,7 +156,8 @@ public class ZooKeeperLockManager extend
             // Unregister all (since we did a global cleanup)
             for (String registeredServiceName : children)
             {
-              connection.deleteChild(registrationNodePath, 
registeredServiceName);
+              if (!registeredServiceName.equals(serviceName))
+                connection.deleteChild(registrationNodePath, 
registeredServiceName);
             }
           }
 
@@ -202,7 +203,7 @@ public class ZooKeeperLockManager extend
         try
         {
           String registrationNodePath = 
buildServiceTypeRegistrationPath(serviceType);
-          List<String> children = 
connection.getNodeChildren(registrationNodePath);
+          List<String> children = connection.getChildren(registrationNodePath);
           int activeServiceCount = 0;
           for (String registeredServiceName : children)
           {
@@ -252,7 +253,7 @@ public class ZooKeeperLockManager extend
           // We find ONE service that is registered but inactive, and clean up 
after that one.
           // Presumably the caller will lather, rinse, and repeat.
           String registrationNodePath = 
buildServiceTypeRegistrationPath(serviceType);
-          List<String> children = 
connection.getNodeChildren(registrationNodePath);
+          List<String> children = connection.getChildren(registrationNodePath);
           String serviceName = null;
           for (String registeredServiceName : children)
           {


Reply via email to