You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2013/12/05 21:27:43 UTC

svn commit: r1548274 - in /manifoldcf/branches/CONNECTORS-781/framework: agents/src/main/java/org/apache/manifoldcf/agents/ agents/src/main/java/org/apache/manifoldcf/agents/outputconnectorpool/ agents/src/main/java/org/apache/manifoldcf/agents/system/...

Author: kwright
Date: Thu Dec  5 20:27:43 2013
New Revision: 1548274

URL: http://svn.apache.org/r1548274
Log:
Add service data

Modified:
    manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/AgentRun.java
    manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/outputconnectorpool/OutputConnectorPool.java
    manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/system/AgentsDaemon.java
    manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/ILockManager.java
    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/LockManager.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/agents/src/main/java/org/apache/manifoldcf/agents/AgentRun.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/AgentRun.java?rev=1548274&r1=1548273&r2=1548274&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/AgentRun.java (original)
+++ manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/AgentRun.java Thu Dec  5 20:27:43 2013
@@ -51,7 +51,7 @@ public class AgentRun extends BaseAgents
     // AgentStop only, and AgentStop will wait until all services become inactive before exiting.
     String processID = ManifoldCF.getProcessID();
     ILockManager lockManager = LockManagerFactory.make(tc);
-    lockManager.registerServiceBeginServiceActivity(agentServiceType, processID, null);
+    lockManager.registerServiceBeginServiceActivity(agentServiceType, processID, null, null);
     try
     {
       // Register a shutdown hook to make sure we signal that the main agents process is going inactive.

Modified: manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/outputconnectorpool/OutputConnectorPool.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/outputconnectorpool/OutputConnectorPool.java?rev=1548274&r1=1548273&r2=1548274&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/outputconnectorpool/OutputConnectorPool.java (original)
+++ manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/outputconnectorpool/OutputConnectorPool.java Thu Dec  5 20:27:43 2013
@@ -37,20 +37,8 @@ public class OutputConnectorPool impleme
 
   // How global connector allocation works:
   // (1) There is a lock-manager "service" associated with this connector pool.  This allows us to clean
-  // up after local pools that have died without being released.  There's one service instance per local pool,
-  // and thus one service instance per JVM.  NOTE WELL: This means that we need distinct process id's
-  // for non-agent services as well!!  How do we do that??
-  // A: -D always overrides processID, but in addition there's a default describing the kind of process it is,
-  // e.g. "" for agents, "AUTH" for authority service, "API" for api service, "UI" for crawler UI, "CL" for
-  // command line.
-  // Next question; how does the process ID get set for these?
-  // A: Good question...
-  // Alternative: SINCE the pools are in-memory-only and static, maybe we can just mint a unique ID for
-  // each pool on each instantiation.
-  // Problem: Guaranteeing uniqueness
-  // Solution: Zookeeper sequential nodes will do that for us, but is there a local/file equivalent?  Must be, but lock manager
-  // needs extension, clearly.  But given that, it should be possible to have a globally-unique, transient "pool ID".
-  // The transient globally-unique ID seems like the best solution.
+  // up after local pools that have died without being released.  There's one anonymous service instance per local pool,
+  // and thus one service instance per JVM.
   // (2) Each local pool knows how many connector instances of each type (keyed by class name and config info) there
   // are.
   // (3) Each local pool/connector instance type has a local authorization count.  This is the amount it's

Modified: manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/system/AgentsDaemon.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/system/AgentsDaemon.java?rev=1548274&r1=1548273&r2=1548274&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/system/AgentsDaemon.java (original)
+++ manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/system/AgentsDaemon.java Thu Dec  5 20:27:43 2013
@@ -267,7 +267,7 @@ public class AgentsDaemon
           {
             // Throw a lock, so that cleanup processes and startup processes don't collide.
             String serviceType = getAgentsClassServiceType(className);
-            lockManager.registerServiceBeginServiceActivity(serviceType, processID, new CleanupAgent(threadContext, agent, processID));
+            lockManager.registerServiceBeginServiceActivity(serviceType, processID, null, new CleanupAgent(threadContext, agent, processID));
             // There is a potential race condition where the agent has been started but hasn't yet appeared in runningHash.
             // But having runningHash be the synchronizer for this activity will prevent any problems.
             agent.startAgent(threadContext, processID);

Modified: manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/ILockManager.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/ILockManager.java?rev=1548274&r1=1548273&r2=1548274&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/ILockManager.java (original)
+++ manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/ILockManager.java Thu Dec  5 20:27:43 2013
@@ -46,13 +46,32 @@ public interface ILockManager
   *@param serviceType is the type of service.
   *@param serviceName is the name of the service to register.  If null is passed, a transient unique service name will be
   *    created, and will be returned to the caller.
+  *@param serviceData is the initial value of the service's transient data, or null if none.
   *@param cleanup is called to clean up either the current service, or all services of this type, if no other active service exists.
   *    May be null.  Local service cleanup is never called if the serviceName argument is null.
   *@return the actual service name.
   */
-  public String registerServiceBeginServiceActivity(String serviceType, String serviceName, IServiceCleanup cleanup)
+  public String registerServiceBeginServiceActivity(String serviceType, String serviceName, byte[] serviceData,
+    IServiceCleanup cleanup)
     throws ManifoldCFException;
   
+  /** Update service data for a service.
+  *@param serviceType is the type of service.
+  *@param serviceName is the name of the service.
+  *@param serviceData is the data to update to (may be null).
+  * This updates the service's transient data (or deletes it).  If the service is not active, an exception is thrown.
+  */
+  public void updateServiceData(String serviceType, String serviceName, byte[] serviceData)
+    throws ManifoldCFException;
+
+  /** Retrieve service data for a service.
+  *@param serviceType is the type of service.
+  *@param serviceName is the name of the service.
+  *@return the service's transient data.
+  */
+  public byte[] retrieveServiceData(String serviceType, String serviceName)
+    throws ManifoldCFException;
+    
   /** Count all active services of a given type.
   *@param serviceType is the service type.
   *@return the count.
@@ -92,6 +111,8 @@ public interface ILockManager
   public boolean checkServiceActive(String serviceType, String serviceName)
     throws ManifoldCFException;
 
+  /** Read specified service-associated data.  The data returned will be blank (empty) if the service
+  * is not active.
   // Configuration
   
   /** Get the current shared configuration.  This configuration is available in common among all nodes,

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=1548274&r1=1548273&r2=1548274&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 Thu Dec  5 20:27:43 2013
@@ -87,6 +87,8 @@ public class BaseLockManager implements 
   protected final static String servicePrefix = "_SERVICE_";
   /** A flag prefix, followed by the service type, and then followed by "_" and the service name */
   protected final static String activePrefix = "_ACTIVE_";
+  /** A data name prefix, followed by the service type, and then followed by "_" and the service name */
+  protected final static String serviceDataPrefix = "_SERVICEDATA_";
   /** Anonymous service name prefix, to be followed by an integer */
   protected final static String anonymousServiceNamePrefix = "_ANON_";
   /** Anonymous global variable name prefix, to be followed by the service type */
@@ -105,12 +107,14 @@ public class BaseLockManager implements 
   *@param serviceType is the type of service.
   *@param serviceName is the name of the service to register.  If null is passed, a transient unique service name will be
   *    created, and will be returned to the caller.
+  *@param serviceData is the initial value of the service's transient data, or null if none.
   *@param cleanup is called to clean up either the current service, or all services of this type, if no other active service exists.
   *    May be null.  Local service cleanup is never called if the serviceName argument is null.
   *@return the actual service name.
   */
   @Override
-  public String registerServiceBeginServiceActivity(String serviceType, String serviceName, IServiceCleanup cleanup)
+  public String registerServiceBeginServiceActivity(String serviceType, String serviceName, byte[] serviceData,
+    IServiceCleanup cleanup)
     throws ManifoldCFException
   {
     enterWriteLock(serviceLock);
@@ -207,6 +211,7 @@ public class BaseLockManager implements 
 
       // Last, set the appropriate active flag
       setGlobalFlag(serviceActiveFlag);
+      writeServiceData(serviceType, serviceName, serviceData);
       return serviceName;
     }
     finally
@@ -215,6 +220,56 @@ public class BaseLockManager implements 
     }
   }
   
+  /** Update service data for a service.
+  *@param serviceType is the type of service.
+  *@param serviceName is the name of the service.
+  *@param serviceData is the data to update to (may be null).
+  * This updates the service's transient data (or deletes it).  If the service is not active, an exception is thrown.
+  */
+  @Override
+  public void updateServiceData(String serviceType, String serviceName, byte[] serviceData)
+    throws ManifoldCFException
+  {
+    enterWriteLock(serviceLock);
+    try
+    {
+      String serviceActiveFlag = makeActiveServiceFlagName(serviceType, serviceName);
+      if (!checkGlobalFlag(serviceActiveFlag))
+        throw new ManifoldCFException("Service '"+serviceName+"' of type '"+serviceType+"' is not active");
+      writeServiceData(serviceType, serviceName, serviceData);
+    }
+    finally
+    {
+      leaveWriteLock(serviceLock);
+    }
+  }
+
+  /** Retrieve service data for a service.
+  *@param serviceType is the type of service.
+  *@param serviceName is the name of the service.
+  *@return the service's transient data.
+  */
+  @Override
+  public byte[] retrieveServiceData(String serviceType, String serviceName)
+    throws ManifoldCFException
+  {
+    enterReadLock(serviceLock);
+    try
+    {
+      String serviceActiveFlag = makeActiveServiceFlagName(serviceType, serviceName);
+      if (!checkGlobalFlag(serviceActiveFlag))
+        return null;
+      byte[] rval = readServiceData(serviceType, serviceName);
+      if (rval == null)
+        rval = new byte[0];
+      return rval;
+    }
+    finally
+    {
+      leaveReadLock(serviceLock);
+    }
+  }
+
   /** Count all active services of a given type.
   *@param serviceType is the service type.
   *@return the count.
@@ -223,7 +278,7 @@ public class BaseLockManager implements 
   public int countActiveServices(String serviceType)
     throws ManifoldCFException
   {
-    enterWriteLock(serviceLock);
+    enterReadLock(serviceLock);
     try
     {
       int count = 0;
@@ -242,55 +297,10 @@ public class BaseLockManager implements 
     }
     finally
     {
-      leaveWriteLock(serviceLock);
+      leaveReadLock(serviceLock);
     }
   }
 
-  /** Construct a unique service name given the service type.
-  */
-  protected String constructUniqueServiceName(String serviceType)
-    throws ManifoldCFException
-  {
-    String serviceCounterName = makeServiceCounterName(serviceType);
-    int serviceUID = readServiceCounter(serviceCounterName);
-    writeServiceCounter(serviceCounterName,serviceUID+1);
-    return anonymousServiceNamePrefix + serviceUID;
-  }
-  
-  /** Make the service counter name for a service type.
-  */
-  protected static String makeServiceCounterName(String serviceType)
-  {
-    return anonymousServiceTypeCounter + serviceType;
-  }
-  
-  /** Read service counter.
-  */
-  protected int readServiceCounter(String serviceCounterName)
-    throws ManifoldCFException
-  {
-    byte[] serviceCounterData = readData(serviceCounterName);
-    if (serviceCounterData == null || serviceCounterData.length != 4)
-      return 0;
-    return ((int)serviceCounterData[0]) & 0xff +
-      (((int)serviceCounterData[1]) << 8) & 0xff00 +
-      (((int)serviceCounterData[2]) << 16) & 0xff0000 +
-      (((int)serviceCounterData[3]) << 24) & 0xff000000;
-  }
-  
-  /** Write service counter.
-  */
-  protected void writeServiceCounter(String serviceCounterName, int counter)
-    throws ManifoldCFException
-  {
-    byte[] serviceCounterData = new byte[4];
-    serviceCounterData[0] = (byte)(counter & 0xff);
-    serviceCounterData[1] = (byte)((counter >> 8) & 0xff);
-    serviceCounterData[2] = (byte)((counter >> 16) & 0xff);
-    serviceCounterData[3] = (byte)((counter >> 24) & 0xff);
-    writeData(serviceCounterName,serviceCounterData);
-  }
-  
   /** Clean up any inactive services found.
   * Calling this method will invoke cleanup of one inactive service at a time.
   * If there are no inactive services around, then false will be returned.
@@ -376,6 +386,7 @@ public class BaseLockManager implements 
       String serviceActiveFlag = makeActiveServiceFlagName(serviceType, serviceName);
       if (!checkGlobalFlag(serviceActiveFlag))
         throw new ManifoldCFException("Service '"+serviceName+"' of type '"+serviceType+" is not active");
+      writeServiceData(serviceType, serviceName, null);
       clearGlobalFlag(serviceActiveFlag);
     }
     finally
@@ -395,17 +406,79 @@ public class BaseLockManager implements 
   public boolean checkServiceActive(String serviceType, String serviceName)
     throws ManifoldCFException
   {
-    enterWriteLock(serviceLock);
+    enterReadLock(serviceLock);
     try
     {
       return checkGlobalFlag(makeActiveServiceFlagName(serviceType, serviceName));
     }
     finally
     {
-      leaveWriteLock(serviceLock);
+      leaveReadLock(serviceLock);
     }
   }
 
+  /** Construct a unique service name given the service type.
+  */
+  protected String constructUniqueServiceName(String serviceType)
+    throws ManifoldCFException
+  {
+    String serviceCounterName = makeServiceCounterName(serviceType);
+    int serviceUID = readServiceCounter(serviceCounterName);
+    writeServiceCounter(serviceCounterName,serviceUID+1);
+    return anonymousServiceNamePrefix + serviceUID;
+  }
+  
+  /** Make the service counter name for a service type.
+  */
+  protected static String makeServiceCounterName(String serviceType)
+  {
+    return anonymousServiceTypeCounter + serviceType;
+  }
+  
+  /** Read service counter.
+  */
+  protected int readServiceCounter(String serviceCounterName)
+    throws ManifoldCFException
+  {
+    byte[] serviceCounterData = readData(serviceCounterName);
+    if (serviceCounterData == null || serviceCounterData.length != 4)
+      return 0;
+    return ((int)serviceCounterData[0]) & 0xff +
+      (((int)serviceCounterData[1]) << 8) & 0xff00 +
+      (((int)serviceCounterData[2]) << 16) & 0xff0000 +
+      (((int)serviceCounterData[3]) << 24) & 0xff000000;
+  }
+  
+  /** Write service counter.
+  */
+  protected void writeServiceCounter(String serviceCounterName, int counter)
+    throws ManifoldCFException
+  {
+    byte[] serviceCounterData = new byte[4];
+    serviceCounterData[0] = (byte)(counter & 0xff);
+    serviceCounterData[1] = (byte)((counter >> 8) & 0xff);
+    serviceCounterData[2] = (byte)((counter >> 16) & 0xff);
+    serviceCounterData[3] = (byte)((counter >> 24) & 0xff);
+    writeData(serviceCounterName,serviceCounterData);
+  }
+  
+  protected void writeServiceData(String serviceType, String serviceName, byte[] serviceData)
+    throws ManifoldCFException
+  {
+    writeData(makeServiceDataName(serviceType, serviceName), serviceData);
+  }
+  
+  protected byte[] readServiceData(String serviceType, String serviceName)
+    throws ManifoldCFException
+  {
+    return readData(makeServiceDataName(serviceType, serviceName));
+  }
+  
+  protected static String makeServiceDataName(String serviceType, String serviceName)
+  {
+    return serviceDataPrefix + serviceType + "_" + serviceName;
+  }
+  
   protected static String makeActiveServiceFlagName(String serviceType, String serviceName)
   {
     return activePrefix + serviceType + "_" + serviceName;

Modified: manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockManager.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockManager.java?rev=1548274&r1=1548273&r2=1548274&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockManager.java (original)
+++ manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/lockmanager/LockManager.java Thu Dec  5 20:27:43 2013
@@ -57,17 +57,44 @@ public class LockManager implements ILoc
   *@param serviceType is the type of service.
   *@param serviceName is the name of the service to register.  If null is passed, a transient unique service name will be
   *    created, and will be returned to the caller.
+  *@param serviceData is the initial value of the service's transient data, or null if none.
   *@param cleanup is called to clean up either the current service, or all services of this type, if no other active service exists.
   *    May be null.  Local service cleanup is never called if the serviceName argument is null.
   *@return the actual service name.
   */
   @Override
-  public String registerServiceBeginServiceActivity(String serviceType, String serviceName, IServiceCleanup cleanup)
+  public String registerServiceBeginServiceActivity(String serviceType, String serviceName, byte[] serviceData,
+    IServiceCleanup cleanup)
     throws ManifoldCFException
   {
-    return lockManager.registerServiceBeginServiceActivity(serviceType, serviceName, cleanup);
+    return lockManager.registerServiceBeginServiceActivity(serviceType, serviceName, serviceData, cleanup);
   }
   
+  /** Update service data for a service.
+  *@param serviceType is the type of service.
+  *@param serviceName is the name of the service.
+  *@param serviceData is the data to update to (may be null).
+  * This updates the service's transient data (or deletes it).  If the service is not active, an exception is thrown.
+  */
+  @Override
+  public void updateServiceData(String serviceType, String serviceName, byte[] serviceData)
+    throws ManifoldCFException
+  {
+    lockManager.updateServiceData(serviceType, serviceName, serviceData);
+  }
+
+  /** Retrieve service data for a service.
+  *@param serviceType is the type of service.
+  *@param serviceName is the name of the service.
+  *@return the service's transient data.
+  */
+  @Override
+  public byte[] retrieveServiceData(String serviceType, String serviceName)
+    throws ManifoldCFException
+  {
+    return lockManager.retrieveServiceData(serviceType, serviceName);
+  }
+
   /** Clean up any inactive services found.
   * Calling this method will invoke cleanup of one inactive service at a time.
   * If there are no inactive services around, then false will be returned.

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=1548274&r1=1548273&r2=1548274&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 Thu Dec  5 20:27:43 2013
@@ -72,12 +72,12 @@ public class ZooKeeperConnection
 
   /** Create a transient node.
   */
-  public void createNode(String nodePath)
+  public void createNode(String nodePath, byte[] nodeData)
     throws ManifoldCFException, InterruptedException
   {
     try
     {
-      zookeeper.create(nodePath, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
+      zookeeper.create(nodePath, nodeData, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
     }
     catch (KeeperException e)
     {
@@ -87,14 +87,49 @@ public class ZooKeeperConnection
   
   /** Check whether a node exists.
   *@param nodePath is the path of the node.
-  *@return true if exists.
+  *@return the data, if the node if exists, otherwise null.
   */
   public boolean checkNodeExists(String nodePath)
     throws ManifoldCFException, InterruptedException
   {
     try
     {
-      return zookeeper.exists(nodePath,false) != null;
+      return (zookeeper.exists(nodePath,false) != null);
+    }
+    catch (KeeperException e)
+    {
+      throw new ManifoldCFException(e.getMessage(),e);
+    }
+  }
+
+  /** Get node data.
+  *@param nodePath is the path of the node.
+  *@return the data, if the node if exists, otherwise null.
+  */
+  public byte[] getNodeData(String nodePath)
+    throws ManifoldCFException, InterruptedException
+  {
+    try
+    {
+      Stat s = zookeeper.exists(nodePath,false);
+      if (s == null)
+        return null;
+      return zookeeper.getData(nodePath,false,s);
+    }
+    catch (KeeperException e)
+    {
+      throw new ManifoldCFException(e.getMessage(),e);
+    }
+  }
+  
+  /** Set node data.
+  */
+  public void setNodeData(String nodePath, byte[] data)
+    throws ManifoldCFException, InterruptedException
+  {
+    try
+    {
+      zookeeper.setData(nodePath,data,-1);
     }
     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=1548274&r1=1548273&r2=1548274&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 Thu Dec  5 20:27:43 2013
@@ -107,12 +107,14 @@ public class ZooKeeperLockManager extend
   *@param serviceType is the type of service.
   *@param serviceName is the name of the service to register.  If null is passed, a transient unique service name will be
   *    created, and will be returned to the caller.
+  *@param serviceData is the initial value of the service's transient data, or null if none.
   *@param cleanup is called to clean up either the current service, or all services of this type, if no other active service exists.
   *    May be null.  Local service cleanup is never called if the serviceName argument is null.
   *@return the actual service name.
   */
   @Override
-  public String registerServiceBeginServiceActivity(String serviceType, String serviceName, IServiceCleanup cleanup)
+  public String registerServiceBeginServiceActivity(String serviceType, String serviceName, byte[] serviceData,
+    IServiceCleanup cleanup)
     throws ManifoldCFException
   {
     try
@@ -185,7 +187,7 @@ public class ZooKeeperLockManager extend
           }
           
           // Last, set the appropriate active flag
-          connection.createNode(activePath);
+          connection.createNode(activePath, (serviceData==null)?new byte[0]:serviceData);
           return serviceName;
         }
         finally
@@ -204,6 +206,75 @@ public class ZooKeeperLockManager extend
     }
   }
   
+  /** Update service data for a service.
+  *@param serviceType is the type of service.
+  *@param serviceName is the name of the service.
+  *@param serviceData is the data to update to (may be null).
+  * This updates the service's transient data (or deletes it).  If the service is not active, an exception is thrown.
+  */
+  public void updateServiceData(String serviceType, String serviceName, byte[] serviceData)
+    throws ManifoldCFException
+  {
+    try
+    {
+      ZooKeeperConnection connection = pool.grab();
+      try
+      {
+        enterServiceRegistryLock(connection, serviceType);
+        try
+        {
+          connection.setNodeData(buildServiceTypeActivePath(serviceType, serviceName), (serviceData==null)?new byte[0]:serviceData);
+        }
+        finally
+        {
+          leaveServiceRegistryLock(connection);
+        }
+      }
+      finally
+      {
+        pool.release(connection);
+      }
+    }
+    catch (InterruptedException e)
+    {
+      throw new ManifoldCFException(e.getMessage(),e,ManifoldCFException.INTERRUPTED);
+    }
+  }
+
+  /** Retrieve service data for a service.
+  *@param serviceType is the type of service.
+  *@param serviceName is the name of the service.
+  *@return the service's transient data.
+  */
+  public byte[] retrieveServiceData(String serviceType, String serviceName)
+    throws ManifoldCFException
+  {
+    try
+    {
+      ZooKeeperConnection connection = pool.grab();
+      try
+      {
+        enterServiceRegistryLock(connection, serviceType);
+        try
+        {
+          return connection.getNodeData(buildServiceTypeActivePath(serviceType, serviceName));
+        }
+        finally
+        {
+          leaveServiceRegistryLock(connection);
+        }
+      }
+      finally
+      {
+        pool.release(connection);
+      }
+    }
+    catch (InterruptedException e)
+    {
+      throw new ManifoldCFException(e.getMessage(),e,ManifoldCFException.INTERRUPTED);
+    }
+  }
+
   /** Count all active services of a given type.
   *@param serviceType is the service type.
   *@return the count.