manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1547644 - in /manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents: interfaces/ outputconnectorpool/
Date Tue, 03 Dec 2013 23:34:15 GMT
Author: kwright
Date: Tue Dec  3 23:34:15 2013
New Revision: 1547644

URL: http://svn.apache.org/r1547644
Log:
Add thread-local output connector pool abstraction

Added:
    manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/IOutputConnectorPool.java
  (with props)
    manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/OutputConnectorPoolFactory.java
  (with props)
    manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/outputconnectorpool/
    manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/outputconnectorpool/OutputConnectorPool.java
  (with props)

Added: manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/IOutputConnectorPool.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/IOutputConnectorPool.java?rev=1547644&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/IOutputConnectorPool.java
(added)
+++ manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/IOutputConnectorPool.java
Tue Dec  3 23:34:15 2013
@@ -0,0 +1,74 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.manifoldcf.agents.interfaces;
+
+import org.apache.manifoldcf.core.interfaces.*;
+
+import java.util.*;
+import java.io.*;
+
+/** An object implementing this interface functions as a pool of output connectors.
+* Coordination and allocation among cluster members is managed within. 
+* These objects are thread-local, so do not share them among threads.
+*/
+public interface IOutputConnectorPool
+{
+  public static final String _rcsid = "@(#)$Id$";
+
+  /** Get multiple output connectors, all at once.  Do this in a particular order
+  * so that any connector exhaustion will not cause a deadlock.
+  *@param orderingKeys are the keys which determine in what order the connectors are obtained.
+  *@param outputConnections are the connections to use the build the connector instances.
+  */
+  public IOutputConnector[] grabMultiple(String[] orderingKeys, IOutputConnection[] outputConnections)
+    throws ManifoldCFException;
+
+  /** Get an output connector.
+  * The connector is specified by an output connection object.
+  *@param outputConnection is the output connection to base the connector instance on.
+  */
+  public IOutputConnector grab(IOutputConnection outputConnection)
+    throws ManifoldCFException;
+
+  /** Release multiple output connectors.
+  *@param connectors are the connector instances to release.
+  */
+  public void releaseMultiple(IOutputConnector[] connectors)
+    throws ManifoldCFException;
+
+  /** Release an output connector.
+  *@param connector is the connector to release.
+  */
+  public void release(IOutputConnector connector)
+    throws ManifoldCFException;
+
+  /** Idle notification for inactive output connector handles.
+  * This method polls all inactive handles.
+  */
+  public void pollAllConnectors()
+    throws ManifoldCFException;
+
+  /** Clean up all open output connector handles.
+  * This method is called when the connector pool needs to be flushed,
+  * to free resources.
+  */
+  public void closeAllConnectors()
+    throws ManifoldCFException;
+
+}

Propchange: manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/IOutputConnectorPool.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/IOutputConnectorPool.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/OutputConnectorPoolFactory.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/OutputConnectorPoolFactory.java?rev=1547644&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/OutputConnectorPoolFactory.java
(added)
+++ manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/OutputConnectorPoolFactory.java
Tue Dec  3 23:34:15 2013
@@ -0,0 +1,55 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.manifoldcf.agents.interfaces;
+
+import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.manifoldcf.agents.system.ManifoldCF;
+
+import java.util.*;
+
+/** Output connector pool manager factory.
+*/
+public class OutputConnectorPoolFactory
+{
+  public static final String _rcsid = "@(#)$Id$";
+
+  // name to use in thread context pool of objects
+  private final static String objectName = "_OutputConnectorPoolMgr_";
+
+  private OutputConnectorPoolFactory()
+  {
+  }
+
+  /** Make an output connector pool handle.
+  *@param tc is the thread context.
+  *@return the handle.
+  */
+  public static IOutputConnectorPool make(IThreadContext tc)
+    throws ManifoldCFException
+  {
+    Object o = tc.get(objectName);
+    if (o == null || !(o instanceof IOutputConnectorPool))
+    {
+      o = new org.apache.manifoldcf.agents.outputconnectorpool.OutputConnectorPool(tc);
+      tc.save(objectName,o);
+    }
+    return (IOutputConnectorPool)o;
+  }
+
+}

Propchange: manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/OutputConnectorPoolFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/OutputConnectorPoolFactory.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: 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=1547644&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/outputconnectorpool/OutputConnectorPool.java
(added)
+++ manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/outputconnectorpool/OutputConnectorPool.java
Tue Dec  3 23:34:15 2013
@@ -0,0 +1,120 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.manifoldcf.agents.outputconnectorpool;
+
+import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.manifoldcf.agents.interfaces.*;
+
+import java.util.*;
+import java.io.*;
+
+/** An implementation of IOutputConnectorPool.
+* Coordination and allocation among cluster members is managed within. 
+* These objects are thread-local, so do not share them among threads.
+*/
+public class OutputConnectorPool implements IOutputConnectorPool
+{
+  public static final String _rcsid = "@(#)$Id$";
+
+  // This implementation is a place-holder for the real one, which will likely fold in the
pooling code
+  // as we strip it out of OutputConnectorFactory.
+
+  /** Thread context */
+  protected final IThreadContext threadContext;
+  
+  /** Constructor */
+  public OutputConnectorPool(IThreadContext threadContext)
+    throws ManifoldCFException
+  {
+    this.threadContext = threadContext;
+  }
+  
+  /** Get multiple output connectors, all at once.  Do this in a particular order
+  * so that any connector exhaustion will not cause a deadlock.
+  *@param orderingKeys are the keys which determine in what order the connectors are obtained.
+  *@param outputConnections are the connections to use the build the connector instances.
+  */
+  public IOutputConnector[] grabMultiple(String[] orderingKeys, IOutputConnection[] outputConnections)
+    throws ManifoldCFException
+  {
+    // For now, use the OutputConnectorFactory method.  This will require us to extract info
+    // from each output connection, however.
+    String[] classNames = new String[outputConnections.length];
+    ConfigParams[] configInfos = new ConfigParams[outputConnections.length];
+    int[] maxPoolSizes = new int[outputConnections.length];
+    
+    for (int i = 0; i < outputConnections.length; i++)
+    {
+      classNames[i] = outputConnections[i].getClassName();
+      configInfos[i] = outputConnections[i].getConfigParams();
+      maxPoolSizes[i] = outputConnections[i].getMaxConnections();
+    }
+    return OutputConnectorFactory.grabMultiple(threadContext,
+      orderingKeys, classNames, configInfos, maxPoolSizes);
+  }
+
+  /** Get an output connector.
+  * The connector is specified by an output connection object.
+  *@param outputConnection is the output connection to base the connector instance on.
+  */
+  public IOutputConnector grab(IOutputConnection outputConnection)
+    throws ManifoldCFException
+  {
+    return OutputConnectorFactory.grab(threadContext, outputConnection.getClassName(),
+      outputConnection.getConfigParams(), outputConnection.getMaxConnections());
+  }
+
+  /** Release multiple output connectors.
+  *@param connectors are the connector instances to release.
+  */
+  public void releaseMultiple(IOutputConnector[] connectors)
+    throws ManifoldCFException
+  {
+    OutputConnectorFactory.releaseMultiple(connectors);
+  }
+
+  /** Release an output connector.
+  *@param connector is the connector to release.
+  */
+  public void release(IOutputConnector connector)
+    throws ManifoldCFException
+  {
+    OutputConnectorFactory.release(connector);
+  }
+
+  /** Idle notification for inactive output connector handles.
+  * This method polls all inactive handles.
+  */
+  public void pollAllConnectors()
+    throws ManifoldCFException
+  {
+    OutputConnectorFactory.pollAllConnectors(threadContext);
+  }
+
+  /** Clean up all open output connector handles.
+  * This method is called when the connector pool needs to be flushed,
+  * to free resources.
+  */
+  public void closeAllConnectors()
+    throws ManifoldCFException
+  {
+    OutputConnectorFactory.closeAllConnectors(threadContext);
+  }
+
+}

Propchange: manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/outputconnectorpool/OutputConnectorPool.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/outputconnectorpool/OutputConnectorPool.java
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message