mcconnell 2004/01/08 04:51:17
Modified:
merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl
Tag: Ver_3_4 AbstractBlock.java Deployer.java
DeploymentRequest.java
merlin/activation/impl/src/test/org/apache/avalon/activation/appliance
Tag: Ver_3_4 RuntimeTestCase.java
merlin/composition/api/src/java/org/apache/avalon/composition/model
Tag: Ver_3_4 ContainmentContext.java
ContainmentModel.java DeploymentContext.java
DeploymentModel.java
merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl
Tag: Ver_3_4 DefaultComponentContext.java
DefaultContainmentContext.java
DefaultContainmentModel.java
DefaultDeploymentContext.java
DefaultDeploymentModel.java
merlin/composition/impl/src/test/org/apache/avalon/composition/model
Tag: Ver_3_4 AbstractTestCase.java
Log:
Include a scalable deployment timout approach that is based on the aggregation of
the timout of contained components. This is a first step and needs to be extended to
support customization of deployment timouts on individual components at the type and
profile levels.
Revision Changes Path
No revision
No revision
1.10.2.6 +18 -23
avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/AbstractBlock.java
Index: AbstractBlock.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/AbstractBlock.java,v
retrieving revision 1.10.2.5
retrieving revision 1.10.2.6
diff -u -r1.10.2.5 -r1.10.2.6
--- AbstractBlock.java 7 Jan 2004 20:34:42 -0000 1.10.2.5
+++ AbstractBlock.java 8 Jan 2004 12:51:16 -0000 1.10.2.6
@@ -205,18 +205,28 @@
//-------------------------------------------------------------------
/**
- * Return an appliance relative to a supplied model.
- * @param model the meta model
+ * Return an appliance relative to a specific path.
+ * @param source the appliance path
* @return the appliance
+ * @exception IllegalArgumentException if the supplied path is invalid
* @exception ApplianceException if an error occurs during appliance
* resolution
*/
- public Appliance locate( DeploymentModel model )
+ public Appliance locate( String source )
{
- return getAppliance( model );
+ DeploymentModel model =
+ getContainmentModel().getModel( source );
+ return locate( model );
}
- private Appliance getAppliance( final DeploymentModel model )
+ /**
+ * Return an appliance relative to a supplied model.
+ * @param model the meta model
+ * @return the appliance
+ * @exception ApplianceException if an error occurs during appliance
+ * resolution
+ */
+ public Appliance locate( DeploymentModel model )
{
return getAppliance( model, true );
}
@@ -240,21 +250,6 @@
}
}
- /**
- * Return an appliance relative to a specific path.
- * @param source the appliance path
- * @return the appliance
- * @exception IllegalArgumentException if the supplied path is invalid
- * @exception ApplianceException if an error occurs during appliance
- * resolution
- */
- public Appliance locate( String source )
- {
- DeploymentModel model =
- getContainmentModel().getModel( source );
- return getAppliance( model );
- }
-
//-------------------------------------------------------------------
// Deployable
//-------------------------------------------------------------------
@@ -301,8 +296,8 @@
for( int i=0; i<startup.length; i++ )
{
final DeploymentModel child = startup[i];
- final Appliance appliance = getAppliance( child );
- deployer.deploy( appliance, timeout );
+ final Appliance appliance = locate( child );
+ deployer.deploy( child );
}
}
finally
1.2.2.4 +24 -7
avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/Deployer.java
Index: Deployer.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/Deployer.java,v
retrieving revision 1.2.2.3
retrieving revision 1.2.2.4
diff -u -r1.2.2.3 -r1.2.2.4
--- Deployer.java 7 Jan 2004 20:34:42 -0000 1.2.2.3
+++ Deployer.java 8 Jan 2004 12:51:16 -0000 1.2.2.4
@@ -52,6 +52,7 @@
import org.apache.avalon.activation.appliance.Deployable;
+import org.apache.avalon.composition.model.DeploymentModel;
import org.apache.avalon.composition.model.ContainmentModel;
import org.apache.avalon.framework.logger.Logger;
@@ -110,7 +111,7 @@
* Deploys the given Deployable, and allows a maximum time
* for the deployment to complete.
*
- * @param deployable the deployable appliance
+ * @param deployable the deployable model
* @param timeout the maximum time to allow for deployment
*
* @throws DeploymentException if the deployment was not
@@ -124,10 +125,10 @@
* @throws InvocationTargetException if the deployment throws a
* Throwable subclass that is NOT of type Exception or Error.
**/
- void deploy( Deployable deployable, long timeout )
+ void deploy( DeploymentModel deployable )
throws Exception
{
- if( deployable == null )
+ if( null == deployable )
{
throw new NullPointerException( "deployable" );
}
@@ -138,7 +139,7 @@
DeploymentRequest req =
new DeploymentRequest( deployable, m_deploymentThread );
m_deploymentFIFO.put( req );
- req.waitForCompletion( timeout );
+ req.waitForCompletion();
}
/**
@@ -166,10 +167,26 @@
while( true )
{
DeploymentRequest req = (DeploymentRequest) m_deploymentFIFO.get();
- Deployable deployable = req.getDeployable();
+ DeploymentModel deployable = req.getDeployable();
+ if( null == deployable.getHandler() )
+ {
+ final String error =
+ "No handler assigned to model: " + deployable;
+ throw new IllegalStateException( error );
+ }
+ if( !( deployable.getHandler() instanceof Deployable ) )
+ {
+ final String error =
+ "Deployment handler assigned to model: " + deployable
+ + " does not implement the deployable contract";
+ throw new IllegalStateException( error );
+ }
+
+ Deployable target = (Deployable) deployable.getHandler();
+
try
{
- deployable.deploy();
+ target.deploy();
req.done();
}
catch( InterruptedException e )
1.2.2.2 +12 -9
avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/DeploymentRequest.java
Index: DeploymentRequest.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/activation/impl/src/java/org/apache/avalon/activation/appliance/impl/DeploymentRequest.java,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -r1.2.2.1 -r1.2.2.2
--- DeploymentRequest.java 7 Jan 2004 12:57:25 -0000 1.2.2.1
+++ DeploymentRequest.java 8 Jan 2004 12:51:16 -0000 1.2.2.2
@@ -55,6 +55,7 @@
import org.apache.avalon.activation.appliance.Deployable;
import org.apache.avalon.activation.appliance.DeploymentException;
import org.apache.avalon.activation.appliance.FatalDeploymentException;
+import org.apache.avalon.composition.model.DeploymentModel;
/**
* A deployment request handler.
@@ -67,8 +68,9 @@
// immutable state
//------------------------------------------------------------
- private final Deployable m_deployable;
+ private final DeploymentModel m_deployable;
private final Thread m_deploymentThread;
+ private long m_timeout;
//------------------------------------------------------------
// mutable state
@@ -82,37 +84,38 @@
// constructor
//------------------------------------------------------------
- DeploymentRequest( Deployable deployable, Thread deploymentThread )
+ DeploymentRequest( DeploymentModel deployable, Thread deploymentThread )
{
m_deployable = deployable;
m_completed = false;
m_interrupted = false;
m_exception = null;
m_deploymentThread = deploymentThread;
+ m_timeout = deployable.getDeploymentTimeout();
}
//------------------------------------------------------------
// implementation
//------------------------------------------------------------
- Deployable getDeployable()
+ DeploymentModel getDeployable()
{
return m_deployable;
}
- void waitForCompletion( long timeout )
+ void waitForCompletion()
throws Exception
{
synchronized( this )
{
- wait( timeout );
+ wait( m_timeout ); // wait for startup
processException();
if( m_completed )
{
return;
}
m_deploymentThread.interrupt();
- wait( timeout );
+ wait( m_timeout ); // wait for shutdown
processException();
if( m_interrupted || m_completed )
{
@@ -120,7 +123,7 @@
"deployment target: ["
+ m_deployable
+ "] did not respond within the timeout period: ["
- + timeout
+ + m_timeout
+ "] and was successfully interrupted.";
throw new DeploymentException( error );
}
@@ -130,7 +133,7 @@
"deployment target: ["
+ m_deployable
+ "] did not respond within the timeout period: ["
- + timeout
+ + m_timeout
+ "] and failed to respond to an interrupt.";
throw new FatalDeploymentException( error );
}
No revision
No revision
1.3.2.3 +9 -8
avalon/merlin/activation/impl/src/test/org/apache/avalon/activation/appliance/RuntimeTestCase.java
Index: RuntimeTestCase.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/activation/impl/src/test/org/apache/avalon/activation/appliance/RuntimeTestCase.java,v
retrieving revision 1.3.2.2
retrieving revision 1.3.2.3
diff -u -r1.3.2.2 -r1.3.2.3
--- RuntimeTestCase.java 7 Jan 2004 20:34:42 -0000 1.3.2.2
+++ RuntimeTestCase.java 8 Jan 2004 12:51:16 -0000 1.3.2.3
@@ -62,20 +62,21 @@
{
//
- // 1. create the root block using the service context
- // and the root containment model
+ // 1. assemble the model during which all dependencies
+ // are resolved (deployment and runtime)
//
- getLogger().debug( "creating root block" );
- Block block = AbstractBlock.createRootBlock( m_system, m_model );
- getLogger().debug( "block: " + block );
+ getLogger().debug( "model assembly" );
+ m_model.assemble();
//
- // 2. assemble the block during which all dependencies
- // are resolved (deployment and runtime)
+ // 2. create the root block using the service context
+ // and the root containment model
//
- block.getContainmentModel().assemble();
+ getLogger().debug( "creating root block" );
+ Block block = AbstractBlock.createRootBlock( m_system, m_model );
+ getLogger().debug( "block: " + block );
//
// 3. deploy the block during which any 'activate on startup'
No revision
No revision
1.1.1.1.2.5 +1 -8
avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/ContainmentContext.java
Index: ContainmentContext.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/ContainmentContext.java,v
retrieving revision 1.1.1.1.2.4
retrieving revision 1.1.1.1.2.5
diff -u -r1.1.1.1.2.4 -r1.1.1.1.2.5
--- ContainmentContext.java 6 Jan 2004 23:16:49 -0000 1.1.1.1.2.4
+++ ContainmentContext.java 8 Jan 2004 12:51:16 -0000 1.1.1.1.2.5
@@ -69,13 +69,6 @@
public interface ContainmentContext extends DeploymentContext
{
/**
- * Return the system context.
- *
- * @return the system context
- */
- SystemContext getSystemContext();
-
- /**
* Return the classloader model.
*
* @return the type manager assigned to the containment model.
1.9.2.7 +1 -26
avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/ContainmentModel.java
Index: ContainmentModel.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/ContainmentModel.java,v
retrieving revision 1.9.2.6
retrieving revision 1.9.2.7
diff -u -r1.9.2.6 -r1.9.2.7
--- ContainmentModel.java 6 Jan 2004 23:16:49 -0000 1.9.2.6
+++ ContainmentModel.java 8 Jan 2004 12:51:16 -0000 1.9.2.7
@@ -99,14 +99,6 @@
*/
String getPartition();
- /**
- * Returns the maximum allowable time for deployment.
- *
- * @return the maximum time expressed in millisecond of how
- * long a deployment may take.
- **/
- long getDeploymentTimeout();
-
/**
* Return the classloader model.
*
@@ -125,23 +117,6 @@
* @return the named model or null if the name is unknown
*/
DeploymentModel getModel( String name );
-
- /**
- * Return a model relative to a supplied dependency.
- * @return a matching model or null if the dependency is unresolvable
- * @exception ModelRuntimeException if an error occurs during model establishment
- */
- //DeploymentModel getModel( DependencyDescriptor dependency )
- // throws ModelRuntimeException;
-
- /**
- * Return a model relative to a supplied stage descriptor.
- * @param stage the stage descriptor
- * @return model of a an stage handler or null if the stage is unresolvable
- * @exception ModelRuntimeException if an error occurs during model establishment
- */
- //DeploymentModel getModel( StageDescriptor stage )
- // throws ModelRuntimeException;
/**
* Addition of a new subsidiary model within
1.2.2.3 +8 -1
avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/DeploymentContext.java
Index: DeploymentContext.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/DeploymentContext.java,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -u -r1.2.2.2 -r1.2.2.3
--- DeploymentContext.java 4 Jan 2004 21:28:59 -0000 1.2.2.2
+++ DeploymentContext.java 8 Jan 2004 12:51:17 -0000 1.2.2.3
@@ -97,6 +97,13 @@
Logger getLogger();
/**
+ * Return the system context.
+ *
+ * @return the system context
+ */
+ SystemContext getSystemContext();
+
+ /**
* Return the dependency graph used to construct
* deployment and decommissioning sequences.
*
1.7.2.5 +9 -1
avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/DeploymentModel.java
Index: DeploymentModel.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/DeploymentModel.java,v
retrieving revision 1.7.2.4
retrieving revision 1.7.2.5
diff -u -r1.7.2.4 -r1.7.2.5
--- DeploymentModel.java 7 Jan 2004 12:45:41 -0000 1.7.2.4
+++ DeploymentModel.java 8 Jan 2004 12:51:17 -0000 1.7.2.5
@@ -166,5 +166,13 @@
*/
DeploymentModel[] getProviders();
+ /**
+ * Returns the maximum allowable time for deployment.
+ *
+ * @return the maximum time expressed in millisecond of how
+ * long a deployment may take.
+ **/
+ long getDeploymentTimeout();
+
}
No revision
No revision
1.1.2.4 +2 -12
avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/Attic/DefaultComponentContext.java
Index: DefaultComponentContext.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/Attic/DefaultComponentContext.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- DefaultComponentContext.java 6 Jan 2004 23:16:49 -0000 1.1.2.3
+++ DefaultComponentContext.java 8 Jan 2004 12:51:17 -0000 1.1.2.4
@@ -144,7 +144,7 @@
File home, File temp, String partition )
{
super(
- logger, partition, name, profile.getMode(),
+ logger, context.getSystemContext(), partition, name, profile.getMode(),
context.getDependencyGraph() );
if( partition == null )
@@ -197,16 +197,6 @@
//==============================================================
// ContainmentContext
//==============================================================
-
- /**
- * Return the system context.
- *
- * @return the system context
- */
- public SystemContext getSystemContext()
- {
- return m_context.getSystemContext();
- }
/**
* Return the containment context.
1.2.2.5 +2 -15
avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentContext.java
Index: DefaultContainmentContext.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentContext.java,v
retrieving revision 1.2.2.4
retrieving revision 1.2.2.5
diff -u -r1.2.2.4 -r1.2.2.5
--- DefaultContainmentContext.java 6 Jan 2004 23:16:49 -0000 1.2.2.4
+++ DefaultContainmentContext.java 8 Jan 2004 12:51:17 -0000 1.2.2.5
@@ -101,8 +101,6 @@
private final ContainmentProfile m_profile;
- private final SystemContext m_system;
-
private final ModelRepository m_repository;
private final ContainmentModel m_parent;
@@ -152,7 +150,7 @@
File home, File temp, ContainmentModel parent,
ContainmentProfile profile, String partition, String name )
{
- super( logger, partition, name, profile.getMode(), graph );
+ super( logger, system, partition, name, profile.getMode(), graph );
if( system == null )
{
@@ -192,7 +190,6 @@
m_repository = new DefaultModelRepository( repository, logger );
- m_system = system;
m_classloader = model;
m_home = home;
m_temp = temp;
@@ -203,16 +200,6 @@
//---------------------------------------------------------
// ContainmentContext
//---------------------------------------------------------
-
- /**
- * Return the system context.
- *
- * @return the system context
- */
- public SystemContext getSystemContext()
- {
- return m_system;
- }
/**
* Return the working directory from which containers may
1.13.2.12 +11 -4
avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java
Index: DefaultContainmentModel.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java,v
retrieving revision 1.13.2.11
retrieving revision 1.13.2.12
diff -u -r1.13.2.11 -r1.13.2.12
--- DefaultContainmentModel.java 7 Jan 2004 12:49:14 -0000 1.13.2.11
+++ DefaultContainmentModel.java 8 Jan 2004 12:51:17 -0000 1.13.2.12
@@ -234,9 +234,16 @@
*/
public long getDeploymentTimeout()
{
- SystemContext system = m_context.getSystemContext();
- Parameters params = system.getSystemParameters();
- return params.getParameterAsLong( "deployment-timeout", 1000 );
+ long n = super.getDeploymentTimeout();
+ if( isAssembled() )
+ {
+ DeploymentModel[] startup = getStartupGraph();
+ for( int i=0; i<startup.length; i++ )
+ {
+ n = ( n + startup[i].getDeploymentTimeout() );
+ }
+ }
+ return n;
}
/**
1.2.2.4 +19 -2
avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultDeploymentContext.java
Index: DefaultDeploymentContext.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultDeploymentContext.java,v
retrieving revision 1.2.2.3
retrieving revision 1.2.2.4
diff -u -r1.2.2.3 -r1.2.2.4
--- DefaultDeploymentContext.java 6 Jan 2004 23:16:49 -0000 1.2.2.3
+++ DefaultDeploymentContext.java 8 Jan 2004 12:51:17 -0000 1.2.2.4
@@ -52,6 +52,7 @@
import org.apache.avalon.composition.model.DependencyGraph;
import org.apache.avalon.composition.model.DeploymentContext;
+import org.apache.avalon.composition.model.SystemContext;
import org.apache.avalon.framework.context.DefaultContext;
import org.apache.avalon.framework.logger.Logger;
@@ -75,6 +76,7 @@
private final Logger m_logger;
private final Mode m_mode;
private final DependencyGraph m_graph;
+ private final SystemContext m_system;
//---------------------------------------------------------
// constructor
@@ -90,7 +92,7 @@
* @param graph the parent deployment assembly graph
*/
public DefaultDeploymentContext(
- Logger logger, String partition, String name,
+ Logger logger, SystemContext system, String partition, String name,
Mode mode, DependencyGraph graph )
{
if( logger == null )
@@ -105,6 +107,10 @@
{
throw new NullPointerException( "mode" );
}
+ if( system == null )
+ {
+ throw new NullPointerException( "system" );
+ }
m_graph = new DependencyGraph( graph );
if( graph != null )
@@ -113,6 +119,7 @@
}
m_logger = logger;
+ m_system = system;
m_partition = partition;
m_name = name;
m_mode = mode;
@@ -122,6 +129,16 @@
//---------------------------------------------------------
// DeploymentContext
//---------------------------------------------------------
+
+ /**
+ * Return the system context.
+ *
+ * @return the system context
+ */
+ public SystemContext getSystemContext()
+ {
+ return m_system;
+ }
/**
* Return the profile name.
1.9.2.8 +19 -2
avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultDeploymentModel.java
Index: DefaultDeploymentModel.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultDeploymentModel.java,v
retrieving revision 1.9.2.7
retrieving revision 1.9.2.8
diff -u -r1.9.2.7 -r1.9.2.8
--- DefaultDeploymentModel.java 7 Jan 2004 12:49:42 -0000 1.9.2.7
+++ DefaultDeploymentModel.java 8 Jan 2004 12:51:17 -0000 1.9.2.8
@@ -53,10 +53,14 @@
import org.apache.avalon.composition.model.DeploymentModel;
import org.apache.avalon.composition.model.DeploymentContext;
import org.apache.avalon.composition.model.DependencyGraph;
+import org.apache.avalon.composition.model.SystemContext;
+import org.apache.avalon.composition.data.Mode;
+
import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.parameters.Parameters;
+
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
-import org.apache.avalon.composition.data.Mode;
/**
@@ -208,5 +212,18 @@
{
boolean equal = super.equals( other );
return equal;
+ }
+
+ /**
+ * Return the maximum allowable duration for the deployment
+ * of the component represented by this model.
+ *
+ * @return the maximum time expressed in millisecond
+ */
+ public long getDeploymentTimeout()
+ {
+ SystemContext sc = m_context.getSystemContext();
+ Parameters params = sc.getSystemParameters();
+ return params.getParameterAsLong( "deployment-timeout", 1000 );
}
}
No revision
No revision
1.2.2.3 +6 -2
avalon/merlin/composition/impl/src/test/org/apache/avalon/composition/model/AbstractTestCase.java
Index: AbstractTestCase.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/test/org/apache/avalon/composition/model/AbstractTestCase.java,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -u -r1.2.2.2 -r1.2.2.3
--- AbstractTestCase.java 6 Jan 2004 23:16:50 -0000 1.2.2.2
+++ AbstractTestCase.java 8 Jan 2004 12:51:17 -0000 1.2.2.3
@@ -90,7 +90,6 @@
public void printContainmentModel( String lead, ContainmentModel model )
{
- System.out.println( lead + "model:" + model );
printDeploymentModel( lead, model );
DeploymentModel[] models = model.getModels();
if( models.length > 0 )
@@ -126,12 +125,17 @@
public void printComponentModel( String lead, ComponentModel model )
{
- System.out.println( lead + "model:" + model );
printDeploymentModel( lead, model );
}
public void printDeploymentModel( String lead, DeploymentModel model )
{
+ System.out.println(
+ lead
+ + "model:"
+ + model + "("
+ + model.getDeploymentTimeout()
+ + ")" );
DeploymentModel[] providers = model.getProviderGraph();
DeploymentModel[] consumers = model.getConsumerGraph();
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]