Return-Path: Delivered-To: apmail-maven-continuum-commits-archive@www.apache.org Received: (qmail 94778 invoked from network); 2 May 2005 17:20:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 May 2005 17:20:59 -0000 Received: (qmail 54869 invoked by uid 500); 2 May 2005 17:18:48 -0000 Delivered-To: apmail-maven-continuum-commits-archive@maven.apache.org Received: (qmail 54726 invoked by uid 500); 2 May 2005 17:18:47 -0000 Mailing-List: contact continuum-commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: continuum-dev@maven.apache.org Delivered-To: mailing list continuum-commits@maven.apache.org Received: (qmail 54642 invoked by uid 99); 2 May 2005 17:18:46 -0000 X-ASF-Spam-Status: No, hits=0.7 required=10.0 tests=NO_REAL_NAME,WEIRD_PORT X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Mon, 02 May 2005 10:18:41 -0700 Received: (qmail 89211 invoked by uid 65534); 2 May 2005 17:17:10 -0000 Message-ID: <20050502171710.89208.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: svn commit: r165648 - /maven/continuum/trunk/continuum-core-it /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/state /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store /maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus /maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum /maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildqueue /maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification /maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store /maven/continuum/trunk/continuum-core/src/test/resources/org/apache/maven/continuum /maven/continuum/trunk/continuum-plexus-application/src/conf /maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc Date: Mon, 02 May 2005 17:17:07 -0000 To: continuum-commits@maven.apache.org From: trygvis@apache.org X-Mailer: svnmailer-1.0.0-dev X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: trygvis Date: Mon May 2 10:17:06 2005 New Revision: 165648 URL: http://svn.apache.org/viewcvs?rev=3D165648&view=3Drev Log: Fixes CONTINUUM-60: checkout in background o The background check outs are implemented with a CheckOutProjectTask and COPTExecutor reading from the check out TaskQueue. o Adding two more states: "checking out" and "updating". o Adding a "project state guard" that's consulted by the ContinuumStore to ensure that the project is in a legal state at all times. This might not = be the ideal solution to this problem but it's good enough for now. o Updated some test to use the utility methods from ModelloJPoxContinuumStoreTest to create projects it's a bit more complica= ted now with the extra state transitions required to create a "new" project. o Updating the integration tests as the tests have to wait for the check ou= t to complete before continuing. o Cleaned up the exception handling in Continuum a bit, making all exception instanciation go through a method to be able to centralize all logging. T= his implies that the core will log every exception it throws. o Removed all logging from the ContinuumXmlRpc interface as the core does it now. The XML RPC clients will still get any exceptions returned as before. Added: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/project/state/ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/project/state/ContinuumProjectStateGuard.java maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/project/state/ContinuumProjectStateGuardException.java maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/project/state/DefaultContinuumProjectStateGuard.java maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/scm/queue/ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/scm/queue/CheckOutTask.java maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/scm/queue/CheckOutTaskExecutor.java maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/con= tinuum/DefaultContinuumTest.java maven/continuum/trunk/continuum-core/src/test/resources/org/apache/mave= n/continuum/DefaultContinuumTest.xml Modified: maven/continuum/trunk/continuum-core-it/continuum.py maven/continuum/trunk/continuum-core-it/it.py maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/DefaultContinuum.java maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/buildcontroller/BuildProjectTaskExecutor.java maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/buildcontroller/DefaultBuildController.java maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/project/ContinuumProjectState.java maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/store/ContinuumStore.java maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/store/ModelloJPoxContinuumStore.java maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus= /components.xml maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/con= tinuum/buildqueue/BuildQueueTest.java maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/con= tinuum/notification/ContinuumNotificationDispatcherTest.java maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/con= tinuum/store/ModelloJPoxContinuumStoreTest.java maven/continuum/trunk/continuum-plexus-application/src/conf/application= .xml maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/c= ontinuum/xmlrpc/DefaultContinuumXmlRpc.java Modified: maven/continuum/trunk/continuum-core-it/continuum.py URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core-it/= continuum.py?rev=3D165648&r1=3D165647&r2=3D165648&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-core-it/continuum.py (original) +++ maven/continuum/trunk/continuum-core-it/continuum.py Mon May 2 10:17:0= 6 2005 @@ -11,6 +11,8 @@ STATE_ERROR =3D "error" STATE_BUILD_SIGNALED =3D "build signaled" STATE_BUILDING =3D "building" +STATE_CHECKING_OUT =3D "checking out" +STATE_UPDATING =3D "updating" =20 server =3D xmlrpclib.Server("http://localhost:8000") =20 @@ -45,8 +47,12 @@ return STATE_BUILD_SIGNALED elif ( state =3D=3D 6 ): return STATE_BUILDING + elif ( state =3D=3D 7 ): + return STATE_CHECKING_OUT + elif ( state =3D=3D 8 ): + return STATE_UPDATING else: - return "UNKNOWN STATE (" + state + ")." + return "UNKNOWN STATE (" + str( state ) + ")." =20 #################################################################### # These methods correspods 1<=3D>1 with the ContinuumXmlRpc interface @@ -154,7 +160,11 @@ self.version =3D map[ "version" ] self.builderId =3D map[ "builderId" ] self.configuration =3D map[ "configuration" ] - self.checkOutScmResult =3D CheckOutScmResult( map[ "checkOutScmRes= ult" ] ) + + if ( map.has_key( "checkOutScmResult" ) ): + self.checkOutScmResult =3D CheckOutScmResult( map[ "checkOutSc= mResult" ] ) + else: + self.checkOutScmResult =3D None =20 def __str__( self ): str =3D "id: " + self.id + os.linesep +\ Modified: maven/continuum/trunk/continuum-core-it/it.py URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core-it/= it.py?rev=3D165648&r1=3D165647&r2=3D165648&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-core-it/it.py (original) +++ maven/continuum/trunk/continuum-core-it/it.py Mon May 2 10:17:06 2005 @@ -165,7 +165,9 @@ =20 build =3D continuum.getBuild( buildId ) =20 - while( build.state =3D=3D continuum.STATE_BUILD_SIGNALED or build.stat= e =3D=3D continuum.STATE_BUILDING ): + while( build.state =3D=3D continuum.STATE_BUILD_SIGNALED or=20 + build.state =3D=3D continuum.STATE_BUILDING or + build.state =3D=3D continuum.STATE_UPDATING ): build =3D continuum.getBuild( buildId ) time.sleep( sleepInterval ) timeout -=3D sleepInterval @@ -175,6 +177,24 @@ =20 return build =20 +def waitForCheckOut( projectId ): + timeout =3D 60 + sleepInterval =3D 0.1 + + project =3D continuum.getProject( projectId ) + + while( project.state =3D=3D continuum.STATE_CHECKING_OUT ): + project =3D continuum.getProject( projectId ) + time.sleep( sleepInterval ) + timeout -=3D sleepInterval + + if ( timeout <=3D 0 ): + fail( "Timeout while waiting for checkout (project id=3D%(id)s= ) to complete" % { "id" : project.id } ) + + assertEquals( "The check out was not successful for project #" + proje= ct.id, continuum.STATE_NEW, project.state ) + + return project + def cleanDirectory( dir ): if ( os.path.isdir( dir ) ): shutil.rmtree( dir ) @@ -336,6 +356,7 @@ initMaven1Project( maven1Project, "cvs", cvsroot, "maven-1" ) progress( "Adding Maven 1 project" ) maven1Id =3D continuum.addMavenOneProject( "file:" + maven1Project + "= /project.xml" ) + waitForCheckOut( maven1Id ); maven1 =3D continuum.getProject( maven1Id ) assertProject( maven1Id, "Maven 1 Project", email, continuum.STATE_NEW= , "1.0", "maven-1", maven1 ) assertCheckedOutFiles( maven1, [ "/project.xml", "/src/main/java/Foo.j= ava" ] ) @@ -372,6 +393,7 @@ initMaven2Project( maven2Project, cvsroot, "maven-2" ) progress( "Adding Maven 2 project" ) maven2Id =3D continuum.addMavenTwoProject( "file:" + maven2Project + "= /pom.xml" ) + waitForCheckOut( maven2Id ); maven2 =3D continuum.getProject( maven2Id ) assertProject( maven2Id, "Maven 2 Project", email, continuum.STATE_NEW= , "2.0-SNAPSHOT", "maven2", maven2 ) =20 @@ -396,6 +418,7 @@ "executable": "ant", "targets" : "clean, build" } ) + waitForCheckOut( antSvnId ); antSvn =3D continuum.getProject( antSvnId ) assertProject( antSvnId, "Ant SVN Project", email, continuum.STATE_NEW= , "3.0", "ant", antSvn ) progress( "Building SVN Ant project" ) @@ -410,6 +433,7 @@ cvsImport( antProject, cvsroot, "ant-cvs" ) antCvsId =3D continuum.addAntProject( "scm:cvs:local:" + basedir + "/c= vsroot:ant-cvs", "Ant CVS Project", email, "3.0", { "executable": "ant", "targets" : "= clean, build"} ) + waitForCheckOut( antCvsId ); antCvs =3D continuum.getProject( antCvsId ) assertProject( antCvsId, "Ant CVS Project", email, continuum.STATE_NEW= , "3.0", "ant", antCvs ) progress( "Building CVS Ant project" ) @@ -424,8 +448,11 @@ =20 progress( "Adding CVS Shell project" ) shellId =3D continuum.addShellProject( "scm:cvs:local:" + basedir + "/= cvsroot:shell", "Shell Project", email, "3.0", - { "executable": "script.sh", "arg= uments" : ""} ) - + {=20 + "executable": "script.sh",=20 + "arguments" : "" + } ) + waitForCheckOut( shellId ); shell =3D continuum.getProject( shellId ) assertProject( shellId, "Shell Project", email, continuum.STATE_NEW, "= 3=2E0", "shell", shell ) =20 Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/mav= en/continuum/DefaultContinuum.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src= /main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=3D165648&r1= =3D165647&r2=3D165648&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/DefaultContinuum.java (original) +++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/DefaultContinuum.java Mon May 2 10:17:06 2005 @@ -40,9 +40,9 @@ import org.apache.maven.continuum.project.MavenOneProject; import org.apache.maven.continuum.project.MavenTwoProject; import org.apache.maven.continuum.project.ShellProject; -import org.apache.maven.continuum.scm.CheckOutScmResult; import org.apache.maven.continuum.scm.ContinuumScm; import org.apache.maven.continuum.scm.ContinuumScmException; +import org.apache.maven.continuum.scm.queue.CheckOutTask; import org.apache.maven.continuum.store.ContinuumStore; import org.apache.maven.continuum.store.ContinuumStoreException; =20 @@ -80,12 +80,6 @@ private BuilderManager builderManager; =20 /** @requirement */ -// private BuildController buildController; - - /** @requirement */ -// private BuildQueue buildQueue; - - /** @requirement */ private TaskQueue buildQueue; =20 /** @requirement */ @@ -107,8 +101,6 @@ // // -------------------------------------------------------------------= --- =20 -// private BuilderThread builderThread; - private Thread builderThreadThread; =20 // -------------------------------------------------------------------= --- @@ -293,9 +285,7 @@ } catch ( ContinuumStoreException ex ) { - getLogger().error( "Error while updating project.", ex ); - - throw new ContinuumException( "Error while updating project fr= om SCM.", ex ); + throw logAndCreateException( "Error while updating project fro= m SCM.", ex ); } } =20 @@ -308,9 +298,7 @@ } catch ( ContinuumStoreException ex ) { - getLogger().error( "Error while updating project configuration= .", ex ); - - throw new ContinuumException( "Error while updating project co= nfiguration.", ex ); + throw logAndCreateException( "Error while updating project con= figuration.", ex ); } } =20 @@ -323,9 +311,7 @@ } catch ( ContinuumStoreException ex ) { - getLogger().error( "Error while updating project.", ex ); - - throw new ContinuumException( "Error while removing project.",= ex ); + logAndCreateException( "Error while removing project.", ex ); } } =20 @@ -340,9 +326,7 @@ } catch ( ContinuumStoreException ex ) { - getLogger().error( "Error while finding all projects.", ex ); - - throw new ContinuumException( "Exception while getting all pro= jects.", ex ); + throw logAndCreateException( "Exception while getting all proj= ects.", ex ); } } =20 @@ -357,9 +341,7 @@ } catch ( ContinuumStoreException ex ) { - getLogger().error( "Error while finding all projects.", ex ); - - throw new ContinuumException( "Exception while getting all pro= jects.", ex ); + throw logAndCreateException( "Exception while getting all proj= ects.", ex ); } } =20 @@ -382,15 +364,11 @@ } catch ( ContinuumStoreException e ) { - getLogger().error( "Error while building project.", e ); - - throw new ContinuumException( "Error while creating build obje= ct.", e ); + throw logAndCreateException( "Error while creating build objec= t=2E", e ); } catch ( TaskQueueException e ) { - getLogger().error( "Error while enqueuing project.", e ); - - throw new ContinuumException( "Error while creating enqueuing = object.", e ); + throw logAndCreateException( "Error while creating enqueuing o= bject.", e ); } } =20 @@ -407,7 +385,7 @@ } catch ( ContinuumStoreException e ) { - throw new ContinuumException( "Unable to retrieve build with i= d =3D " + buildId, e ); + throw logAndCreateException( "Unable to retrieve build with id= =3D " + buildId, e ); } } =20 @@ -420,7 +398,7 @@ } catch ( ContinuumStoreException e ) { - throw new ContinuumException( "Cannot retrieve builds for proj= ect with id =3D " + projectId, e ); + throw logAndCreateException( "Cannot retrieve builds for proje= ct with id =3D " + projectId, e ); } } =20 @@ -433,7 +411,7 @@ } catch ( ContinuumStoreException e ) { - throw new ContinuumException( "Cannot retrieve build result fo= r build with id =3D " + buildId, e ); + throw logAndCreateException( "Cannot retrieve build result for= build with id =3D " + buildId, e ); } } =20 @@ -446,7 +424,7 @@ } catch ( ContinuumStoreException e ) { - throw new ContinuumException( "Cannot retrieve build result fo= r build with id =3D " + buildId, e ); + throw logAndCreateException( "Cannot retrieve build result for= build with id =3D " + buildId, e ); } } =20 @@ -655,7 +633,7 @@ } catch ( ContinuumStoreException e ) { - throw new ContinuumException( "Error while updating the projec= t=2E", e ); + throw logAndCreateException( "Error while updating the project= .", e ); } } =20 @@ -681,26 +659,30 @@ private ContinuumProject addProjectAndCheckOutSources( ContinuumProjec= t project, String builderType ) throws ContinuumException { + String projectId; + + File projectWorkingDirectory; + try { // -----------------------------------------------------------= ----------- // Store the project // -----------------------------------------------------------= ----------- =20 - String projectId =3D store.addProject( project.getName(), - project.getScmUrl(), - project.getNagEmailAddres= s(), - project.getVersion(), - builderType, - null, - project.getConfiguration(= ) ); + projectId =3D store.addProject( project.getName(), + project.getScmUrl(), + project.getNagEmailAddress(), + project.getVersion(), + builderType, + null, + project.getConfiguration() ); =20 // -----------------------------------------------------------= ----------- // Set the working directory // -----------------------------------------------------------= ----------- =20 =20 - File projectWorkingDirectory =3D new File( workingDirectory, p= rojectId ); + projectWorkingDirectory =3D new File( workingDirectory, projec= tId ); =20 if ( !projectWorkingDirectory.exists() && !projectWorkingDirec= tory.mkdirs() ) { @@ -714,27 +696,24 @@ // -----------------------------------------------------------= ----------- =20 store.setWorkingDirectory( projectId, projectWorkingDirectory.= getAbsolutePath() ); - - CheckOutScmResult result =3D scm.checkOutProject( project ); - - store.setProjectCheckOutScmResult( projectId, result ); - - project =3D store.getProject( projectId ); - - return project; } - catch ( ContinuumScmException ex ) + catch ( ContinuumStoreException ex ) { - getLogger().error( "Exception while checking out the project."= , ex ); - - throw new ContinuumException( "Exception while checking out th= e project.", ex ); + throw logAndCreateException( "Exception while adding project."= , ex ); } - catch ( ContinuumStoreException ex ) + + try { - getLogger().error( "Exception while adding project.", ex ); + CheckOutTask checkOutTask =3D new CheckOutTask( projectId, pro= jectWorkingDirectory ); =20 - throw new ContinuumException( "Exception while adding project.= ", ex ); + checkOutQueue.put( checkOutTask ); + } + catch ( TaskQueueException e ) + { + throw logAndCreateException( "Exception while adding the proje= ct to the check out queue.", e ); } + + return getProject( projectId ); } =20 private void doTempCheckOut( ContinuumProject project ) @@ -750,14 +729,14 @@ } catch ( IOException ex ) { - throw new ContinuumException( "Error while cleaning out " = + checkoutDirectory.getAbsolutePath() ); + throw logAndCreateException( "Error while cleaning out " += checkoutDirectory.getAbsolutePath() ); } } else { if ( !checkoutDirectory.mkdirs() ) { - throw new ContinuumException( "Could not make the check ou= t directory (" + checkoutDirectory.getAbsolutePath() + ")." ); + throw logAndCreateException( "Could not make the check out= directory (" + checkoutDirectory.getAbsolutePath() + ")." ); } } =20 @@ -770,7 +749,7 @@ } catch ( ContinuumScmException e ) { - throw new ContinuumException( "Error while checking out the pr= oject.", e ); + throw logAndCreateException( "Error while checking out the pro= ject.", e ); } } =20 @@ -803,7 +782,7 @@ } catch ( ContinuumStoreException e ) { - throw new ContinuumException( "Error while storing the updated= project.", e ); + throw logAndCreateException( "Error while storing the updated = project.", e ); } =20 getLogger().info( "Updated project: " + project.getName() ); @@ -824,14 +803,14 @@ { if ( !wdFile.isDirectory() ) { - throw new ContinuumException( "The specified working direc= tory isn't a directory: " + wdFile.getAbsolutePath() ); + throw logAndCreateException( "The specified working direct= ory isn't a directory: " + wdFile.getAbsolutePath() ); } } else { if ( !wdFile.mkdirs() ) { - throw new ContinuumException( "Could not making the workin= g directory: " + wdFile.getAbsolutePath() ); + throw logAndCreateException( "Could not making the working= directory: " + wdFile.getAbsolutePath() ); } } =20 @@ -850,20 +829,6 @@ { getLogger().info( "Starting Continuum." ); =20 - // start the builder thread -/* - builderThread =3D new BuilderThread( buildController, buildQueue, = getLogger() ); - - builderThreadThread =3D new Thread( builderThread ); - - builderThreadThread.setDaemon( true ); - - builderThreadThread.start(); -*/ - // ---------------------------------------------------------------= ------- - // - // ---------------------------------------------------------------= ------- - // check to see if the tables exists or not. File file =3D new File( appHome, "continuum.properties" ); =20 @@ -908,43 +873,7 @@ throws Exception { getLogger().info( "Stopping Continuum." ); -/* - int maxSleep =3D 10 * 1000; // 10 seconds - int interval =3D 1000; - int slept =3D 0; - - // signal the thread to stop - builderThread.shutdown(); - - builderThreadThread.interrupt(); - - while ( !builderThread.isDone() ) - { - if ( slept > maxSleep ) - { - getLogger().warn( "Timeout, stopping Continuum." ); - - break; - } - - getLogger().info( "Waiting until Continuum is idling..." ); - - try - { - synchronized ( builderThread ) - { - builderThread.wait( interval ); - } - } - catch ( InterruptedException ex ) - { - // ignore - } =20 - // TODO: should use System.currentTimeMillis() - slept +=3D interval; - } -*/ getLogger().info( "Continuum stopped." ); } =20 @@ -960,5 +889,19 @@ properties.setProperty( DATABASE_INITIALIZED, "true" ); =20 properties.store( new FileOutputStream( file ), null ); + } + + private ContinuumException logAndCreateException( String message ) + { + getLogger().error( message ); + + return new ContinuumException( message ); + } + + private ContinuumException logAndCreateException( String message, Thro= wable cause ) + { + getLogger().error( message, cause ); + + return new ContinuumException( message, cause ); } } Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/mav= en/continuum/buildcontroller/BuildProjectTaskExecutor.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src= /main/java/org/apache/maven/continuum/buildcontroller/BuildProjectTaskExecu= tor.java?rev=3D165648&r1=3D165647&r2=3D165648&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/buildcontroller/BuildProjectTaskExecutor.java (original) +++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/buildcontroller/BuildProjectTaskExecutor.java Mon May 2 10:17:06 20= 05 @@ -19,9 +19,8 @@ import org.apache.maven.continuum.buildqueue.BuildProjectTask; =20 import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializabl= e; -import org.codehaus.plexus.taskqueue.execution.TaskExecutor; import org.codehaus.plexus.taskqueue.Task; +import org.codehaus.plexus.taskqueue.execution.TaskExecutor; =20 /** * @author Trygve Laugstøl @@ -29,24 +28,15 @@ */ public class BuildProjectTaskExecutor extends AbstractLogEnabled - implements TaskExecutor, Initializable + implements TaskExecutor { private BuildController controller; =20 // -------------------------------------------------------------------= --- - // Component Lifecycle - // -------------------------------------------------------------------= --- - - public void initialize() - { - } - - // -------------------------------------------------------------------= --- // TaskExecutor Implementation // -------------------------------------------------------------------= --- =20 public void executeTask( Task task ) - throws Exception { BuildProjectTask buildProjectTask =3D (BuildProjectTask) task; =20 Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/mav= en/continuum/buildcontroller/DefaultBuildController.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src= /main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildControlle= r=2Ejava?rev=3D165648&r1=3D165647&r2=3D165648&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/buildcontroller/DefaultBuildController.java (original) +++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/buildcontroller/DefaultBuildController.java Mon May 2 10:17:06 2005 @@ -60,17 +60,6 @@ =20 public void build( String buildId ) { - try - { - store.setBuildResult( buildId, ContinuumProjectState.BUILDING,= null, null ); - } - catch ( ContinuumStoreException ex ) - { - getLogger().error( "Exception while setting the state flag.", = ex ); - - return; - } - ContinuumProject project; =20 ContinuumBuild build; @@ -198,11 +187,13 @@ =20 try { + store.setIsUpdating( build.getId() ); + notifier.checkoutStarted( build ); =20 scmResult =3D scm.updateProject( project ); =20 - store.setBuildUpdateScmResult( build.getId(), scmResult ); + store.setUpdateDone( build.getId(), scmResult ); } finally { Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/mav= en/continuum/project/ContinuumProjectState.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src= /main/java/org/apache/maven/continuum/project/ContinuumProjectState.java?re= v=3D165648&r1=3D165647&r2=3D165648&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/project/ContinuumProjectState.java (original) +++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/project/ContinuumProjectState.java Mon May 2 10:17:06 2005 @@ -68,6 +68,10 @@ // public final static ContinuumProjectState BUILDING =3D new Continuum= ProjectState( "building" ); public final static int BUILDING =3D 6; =20 + public final static int CHECKING_OUT =3D 7; + + public final static int UPDATING =3D 8; + private String name; =20 protected ContinuumProjectState( String name ) Added: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/= continuum/project/state/ContinuumProjectStateGuard.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src= /main/java/org/apache/maven/continuum/project/state/ContinuumProjectStateGu= ard.java?rev=3D165648&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/project/state/ContinuumProjectStateGuard.java (added) +++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/project/state/ContinuumProjectStateGuard.java Mon May 2 10:17:06 20= 05 @@ -0,0 +1,40 @@ +package org.apache.maven.continuum.project.state; + +/* + * Copyright 2004-2005 The Apache Software Foundation. + * + * Licensed 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. + */ + +import org.apache.maven.continuum.project.ContinuumProject; + +/** + * @author Trygve Laugstøl + * @version $Id:$ + */ +public interface ContinuumProjectStateGuard +{ + String ROLE =3D ContinuumProjectStateGuard.class.getName(); + + void assertTransition( ContinuumProject project, int newState ) + throws ContinuumProjectStateGuardException; + + void assertDeletable( ContinuumProject project ) + throws ContinuumProjectStateGuardException; + + void assertUpdatable( ContinuumProject project ) + throws ContinuumProjectStateGuardException; + + void assertCanChangeWorkingDirectory( ContinuumProject project ) + throws ContinuumProjectStateGuardException; +} Added: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/= continuum/project/state/ContinuumProjectStateGuardException.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src= /main/java/org/apache/maven/continuum/project/state/ContinuumProjectStateGu= ardException.java?rev=3D165648&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/project/state/ContinuumProjectStateGuardException.java (added) +++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/project/state/ContinuumProjectStateGuardException.java Mon May 2 10= :17:06 2005 @@ -0,0 +1,35 @@ +package org.apache.maven.continuum.project.state; + +/* + * Copyright 2004-2005 The Apache Software Foundation. + * + * Licensed 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. + */ + +/** + * @author Trygve Laugstøl + * @version $Id:$ + */ +public class ContinuumProjectStateGuardException + extends Exception +{ + public ContinuumProjectStateGuardException( String message ) + { + super( message ); + } + + public ContinuumProjectStateGuardException( String message, Throwable = cause ) + { + super( message, cause ); + } +} Added: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/= continuum/project/state/DefaultContinuumProjectStateGuard.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src= /main/java/org/apache/maven/continuum/project/state/DefaultContinuumProject= StateGuard.java?rev=3D165648&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/project/state/DefaultContinuumProjectStateGuard.java (added) +++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/project/state/DefaultContinuumProjectStateGuard.java Mon May 2 10:1= 7:06 2005 @@ -0,0 +1,269 @@ +package org.apache.maven.continuum.project.state; + +/* + * Copyright 2004-2005 The Apache Software Foundation. + * + * Licensed 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. + */ + +import org.apache.maven.continuum.project.ContinuumProject; +import org.apache.maven.continuum.project.ContinuumProjectState; + +import org.codehaus.plexus.logging.AbstractLogEnabled; + +/** + * @author Trygve Laugstøl + * @version $Id:$ + */ +public class DefaultContinuumProjectStateGuard + extends AbstractLogEnabled + implements ContinuumProjectStateGuard +{ + // -------------------------------------------------------------------= --- + // ContinuumProjectStateGuard Implementation + // -------------------------------------------------------------------= --- + + private final static int[] NEW_PREVIOUS_STATES =3D { + ContinuumProjectState.CHECKING_OUT, + }; + + private final static int[] ERROR_PREVIOUS_STATES =3D { + ContinuumProjectState.CHECKING_OUT, + }; + + private final static int[] BUILD_SIGNALED_PREVIOUS_STATES =3D { + ContinuumProjectState.NEW, + ContinuumProjectState.ERROR, + ContinuumProjectState.OK, + ContinuumProjectState.FAILED, + ContinuumProjectState.BUILD_SIGNALED, + }; + + private final static int[] UPDATING_PREVIOUS_STATES =3D { + ContinuumProjectState.BUILD_SIGNALED, + }; + + private final static int[] BUILDING_PREVIOUS_STATES =3D { + ContinuumProjectState.UPDATING, + }; + + private final static int[] OK_PREVIOUS_STATES =3D { + ContinuumProjectState.BUILDING, + }; + + private final static int[] FAILED_PREVIOUS_STATES =3D { + ContinuumProjectState.BUILDING, + }; + + private final static int[] DELETABLE_PREVIOUS_STATES =3D { + ContinuumProjectState.NEW, + ContinuumProjectState.ERROR, + ContinuumProjectState.OK, + ContinuumProjectState.FAILED, + }; + + private static final int[] UPDATABLE_PREVIOUS_STATES =3D { + ContinuumProjectState.NEW, + ContinuumProjectState.ERROR, + ContinuumProjectState.OK, + ContinuumProjectState.FAILED, + ContinuumProjectState.BUILDING, + ContinuumProjectState.CHECKING_OUT, + }; + + private static final int[] CHANGE_WORKING_DIRECTORY_PREVIOUS_STATES = =3D { + ContinuumProjectState.CHECKING_OUT, + }; + + // -------------------------------------------------------------------= --- + // ContinuumProjectStateGuard Implementation + // -------------------------------------------------------------------= --- + + public void assertTransition( ContinuumProject project, int newState ) + throws ContinuumProjectStateGuardException + { + if ( newState =3D=3D ContinuumProjectState.NEW ) + { + assertInStates( project.getState(), NEW_PREVIOUS_STATES, "new"= ); + } + else if ( newState =3D=3D ContinuumProjectState.ERROR ) + { + assertInStates( project.getState(), ERROR_PREVIOUS_STATES, "er= ror" ); + } + else if ( newState =3D=3D ContinuumProjectState.UPDATING ) + { + assertInStates( project.getState(), UPDATING_PREVIOUS_STATES, = "updating" ); + } + else if ( newState =3D=3D ContinuumProjectState.BUILD_SIGNALED ) + { + assertInStates( project.getState(), BUILD_SIGNALED_PREVIOUS_ST= ATES, "build signaled" ); + } + else if ( newState =3D=3D ContinuumProjectState.BUILDING ) + { + assertInStates( project.getState(), BUILDING_PREVIOUS_STATES, = "building" ); + } + else if ( newState =3D=3D ContinuumProjectState.OK ) + { + assertInStates( project.getState(), OK_PREVIOUS_STATES, "ok" ); + } + else if ( newState =3D=3D ContinuumProjectState.FAILED ) + { + assertInStates( project.getState(), FAILED_PREVIOUS_STATES, "f= ailed" ); + } + else + { + throw new ContinuumProjectStateGuardException( "Unknown state = '" + newState + "'." ); + } + } + + public void assertDeletable( ContinuumProject project ) + throws ContinuumProjectStateGuardException + { + int[] expectedStates =3D DELETABLE_PREVIOUS_STATES; + + int actualState =3D project.getState(); + + if ( isInState( expectedStates, actualState ) ) + { + return; + } + + String stateString =3D makeStateString( expectedStates ); + + throw new ContinuumProjectStateGuardException( + "To be able to delete a project the project as to be in one of= the states in " + stateString + " " + + "but the project was in the '" + decodeState( actualState ) + = "' state." ); + } + + public void assertUpdatable( ContinuumProject project ) + throws ContinuumProjectStateGuardException + { + int[] expectedStates =3D UPDATABLE_PREVIOUS_STATES; + + int actualState =3D project.getState(); + + if ( isInState( expectedStates, actualState ) ) + { + return; + } + + String stateString =3D makeStateString( expectedStates ); + + throw new ContinuumProjectStateGuardException( + "To be able to update a project the project as to be in one of= the states in " + stateString + " " + + "but the project was in the '" + decodeState( actualState ) + = "' state." ); + } + + public void assertCanChangeWorkingDirectory( ContinuumProject project ) + throws ContinuumProjectStateGuardException + { + int[] expectedStates =3D CHANGE_WORKING_DIRECTORY_PREVIOUS_STATES; + + int actualState =3D project.getState(); + + if ( isInState( expectedStates, actualState ) ) + { + return; + } + + String stateString =3D makeStateString( expectedStates ); + + throw new ContinuumProjectStateGuardException( + "To be able to change the working directory of a project the "= + + "project as to be in one of the states in " + stateString + " = " + + "but the project was in the '" + decodeState( actualState ) + = "' state." ); + } + + // -------------------------------------------------------------------= --- + // + // -------------------------------------------------------------------= --- + + private static void assertInStates( int actualState, + int[] expectedStates, + String actionName ) + throws ContinuumProjectStateGuardException + { + if ( isInState( expectedStates, actualState ) ) + return; + + String stateString =3D makeStateString( expectedStates ); + + throw new ContinuumProjectStateGuardException( + "To be able to go into the state '" + actionName + "', " + + "the project as to be in one of the states in " + stateString = + " " + + "but the project was in the '" + decodeState( actualState ) + = "' state." ); + } + + private static boolean isInState( int[] expectedStates, + int actualState ) + { + for ( int i =3D 0; i < expectedStates.length; i++ ) + { + int expectedState =3D expectedStates[ i ]; + + if ( actualState =3D=3D expectedState ) + { + return true; + } + } + + return false; + } + + private static String makeStateString( int[] states ) + { + String stateString =3D "["; + + for ( int i =3D 0; i < states.length; i++ ) + { + int expectedState =3D states[ i ]; + + if ( i > 0 ) + { + stateString +=3D ", "; + } + + stateString +=3D "'" + decodeState( expectedState ) + "'"; + } + + stateString +=3D "]"; + + return stateString; + } + + // TODO: Externalize + private static String decodeState( int state ) + { + switch ( state ) + { + case ContinuumProjectState.NEW: + return "new"; + case ContinuumProjectState.OK: + return "ok"; + case ContinuumProjectState.FAILED: + return "failed"; + case ContinuumProjectState.ERROR: + return "error"; + case ContinuumProjectState.BUILD_SIGNALED: + return "build signaled"; + case ContinuumProjectState.BUILDING: + return "building"; + case ContinuumProjectState.CHECKING_OUT: + return "checking out"; + case ContinuumProjectState.UPDATING: + return "updating"; + default: + return "UNKNOWN (id '" + state + "')"; + } + } +} Added: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/= continuum/scm/queue/CheckOutTask.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src= /main/java/org/apache/maven/continuum/scm/queue/CheckOutTask.java?rev=3D165= 648&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/scm/queue/CheckOutTask.java (added) +++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/scm/queue/CheckOutTask.java Mon May 2 10:17:06 2005 @@ -0,0 +1,50 @@ +package org.apache.maven.continuum.scm.queue; + +/* + * Copyright 2004-2005 The Apache Software Foundation. + * + * Licensed 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. + */ + +import java.io.File; + +import org.codehaus.plexus.taskqueue.Task; + +/** + * @author Trygve Laugstøl + * @version $Id:$ + */ +public class CheckOutTask + implements Task +{ + private String projectId; + + private File workingDirectory; + + public CheckOutTask( String projectId, File workingDirectory ) + { + this.projectId =3D projectId; + + this.workingDirectory =3D workingDirectory; + } + + public String getProjectId() + { + return projectId; + } + + public File getWorkingDirectory() + { + return workingDirectory; + } +} Added: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/= continuum/scm/queue/CheckOutTaskExecutor.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src= /main/java/org/apache/maven/continuum/scm/queue/CheckOutTaskExecutor.java?r= ev=3D165648&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/scm/queue/CheckOutTaskExecutor.java (added) +++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/scm/queue/CheckOutTaskExecutor.java Mon May 2 10:17:06 2005 @@ -0,0 +1,91 @@ +package org.apache.maven.continuum.scm.queue; + +/* + * Copyright 2004-2005 The Apache Software Foundation. + * + * Licensed 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. + */ + +import java.io.File; + +import org.apache.maven.continuum.scm.ContinuumScm; +import org.apache.maven.continuum.scm.ContinuumScmException; +import org.apache.maven.continuum.scm.CheckOutScmResult; +import org.apache.maven.continuum.store.ContinuumStore; +import org.apache.maven.continuum.store.ContinuumStoreException; +import org.apache.maven.continuum.project.ContinuumProject; + +import org.codehaus.plexus.logging.AbstractLogEnabled; +import org.codehaus.plexus.taskqueue.Task; +import org.codehaus.plexus.taskqueue.execution.TaskExecutor; +import org.codehaus.plexus.taskqueue.execution.TaskExecutionException; + +/** + * @author Trygve Laugstøl + * @version $Id:$ + */ +public class CheckOutTaskExecutor + extends AbstractLogEnabled + implements TaskExecutor +{ + /** @requirement */ + private ContinuumScm scm; + + /** @requirement */ + private ContinuumStore store; + + // -------------------------------------------------------------------= --- + // TaskExecutor Implementation + // -------------------------------------------------------------------= --- + + public void executeTask( Task t ) + throws TaskExecutionException + { + CheckOutTask task =3D (CheckOutTask) t; + + String projectId =3D task.getProjectId(); + + File workingDirectory =3D task.getWorkingDirectory(); + + ContinuumProject project; + + try + { + project =3D store.getProject( projectId ); + } + catch ( ContinuumStoreException e ) + { + throw new TaskExecutionException( "Error while reading the pro= ject from the store.", e ); + } + + CheckOutScmResult result; + + try + { + result =3D scm.checkOut( project, workingDirectory ); + } + catch ( ContinuumScmException e ) + { + throw new TaskExecutionException( "Error while reading the pro= ject from the store.", e ); + } + + try + { + store.setCheckoutDone( projectId, result ); + } + catch ( ContinuumStoreException e ) + { + throw new TaskExecutionException( "Error while storing the che= ck out result.", e ); + } + } +} Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/mav= en/continuum/store/ContinuumStore.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src= /main/java/org/apache/maven/continuum/store/ContinuumStore.java?rev=3D16564= 8&r1=3D165647&r2=3D165648&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/store/ContinuumStore.java (original) +++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/store/ContinuumStore.java Mon May 2 10:17:06 2005 @@ -57,9 +57,6 @@ void setWorkingDirectory( String projectId, String workingDirectory ) throws ContinuumStoreException; =20 - void setProjectCheckOutScmResult( String projectId, CheckOutScmResult = result ) - throws ContinuumStoreException; - void updateProject( String projectId, String name, String scmUrl, Stri= ng nagEmailAddress, String version ) throws ContinuumStoreException; =20 @@ -106,6 +103,16 @@ List getChangedFilesForBuild( String buildId ) throws ContinuumStoreException; =20 - void setBuildUpdateScmResult( String buildId, UpdateScmResult scmResul= t ) + // -------------------------------------------------------------------= --- + // SCM + // -------------------------------------------------------------------= --- + + void setCheckoutDone( String projectId, CheckOutScmResult scmResult ) + throws ContinuumStoreException; + + void setIsUpdating( String buildId ) + throws ContinuumStoreException; + + void setUpdateDone( String buildId, UpdateScmResult scmResult ) throws ContinuumStoreException; } Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/mav= en/continuum/store/ModelloJPoxContinuumStore.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src= /main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java?= rev=3D165648&r1=3D165647&r2=3D165648&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/store/ModelloJPoxContinuumStore.java (original) +++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/con= tinuum/store/ModelloJPoxContinuumStore.java Mon May 2 10:17:06 2005 @@ -31,6 +31,7 @@ import org.apache.maven.continuum.project.ContinuumJPoxStore; import org.apache.maven.continuum.project.ContinuumProject; import org.apache.maven.continuum.project.ContinuumProjectState; +import org.apache.maven.continuum.project.state.ContinuumProjectStateGuard; import org.apache.maven.continuum.scm.CheckOutScmResult; import org.apache.maven.continuum.scm.ScmFile; import org.apache.maven.continuum.scm.UpdateScmResult; @@ -49,6 +50,9 @@ /** @requirement */ private JdoFactory jdoFactory; =20 + /** @requirement */ + private ContinuumProjectStateGuard projectStateGuard; + private ContinuumJPoxStore store; =20 // -------------------------------------------------------------------= --- @@ -94,7 +98,7 @@ project.setVersion( version ); project.setBuilderId( builderId ); project.setWorkingDirectory( workingDirectory ); - project.setState( ContinuumProjectState.NEW ); + project.setState( ContinuumProjectState.CHECKING_OUT ); project.setConfiguration( configuration ); =20 try @@ -125,11 +129,15 @@ // System.err.println( "getProject()" ); ContinuumProject project =3D store.getContinuumProject( projec= tId, false ); =20 - // TODO: This is dumb. + projectStateGuard.assertDeletable( project ); + + // TODO: This whole section is dumb. PersistenceManager pm =3D store.getThreadState().getPersistenc= eManager(); =20 -// System.err.println( "getBuilds()" ); - for ( Iterator it =3D project.getBuilds().iterator(); it.hasNe= xt(); ) +// System.err.println( "project.getBuilds()" ); + List builds =3D project.getBuilds(); + + for ( Iterator it =3D builds.iterator(); it.hasNext(); ) { ContinuumBuild build =3D (ContinuumBuild) it.next(); =20 @@ -155,10 +163,10 @@ =20 // System.err.println( "pm.deletePersistent( result )" ); pm.deletePersistent( result ); - } =20 -// System.err.println( "project.getBuilds()" ); - List builds =3D new ArrayList( project.getBuilds() ); +// System.err.println( "build.setProject( null )" ); + build.setProject( null ); + } =20 for ( Iterator it =3D builds.iterator(); it.hasNext(); ) { @@ -166,10 +174,12 @@ =20 // System.err.println( "build.setProject( null )" ); build.setProject( null ); + + pm.deletePersistent( build ); } =20 // System.err.println( "pm.deletePersistentAll( builds )" ); - pm.deletePersistentAll( project.getBuilds() ); + pm.deletePersistentAll( builds ); =20 // System.err.println( "store.deleteContinuumProject( projectId= )" ); store.deleteContinuumProject( projectId ); @@ -193,6 +203,8 @@ =20 ContinuumProject project =3D store.getContinuumProject( projec= tId, false ); =20 + projectStateGuard.assertCanChangeWorkingDirectory( project ); + project.setWorkingDirectory( workingDirectory ); =20 store.commit(); @@ -205,27 +217,6 @@ } } =20 - public void setProjectCheckOutScmResult( String projectId, CheckOutScm= Result result ) - throws ContinuumStoreException - { - try - { - store.begin(); - - ContinuumProject project =3D store.getContinuumProject( projec= tId, false ); - - project.setCheckOutScmResult( result ); - - store.commit(); - } - catch ( Exception e ) - { - rollback( store ); - - throw new ContinuumStoreException( "Error while setting scm ch= eck out result for project with id: '" + projectId + "'.", e ); - } - } - public void updateProject( String projectId, String name, String scmUr= l, String nagEmailAddress, String version ) throws ContinuumStoreException { @@ -235,6 +226,8 @@ =20 ContinuumProject project =3D store.getContinuumProject( projec= tId, false ); =20 + projectStateGuard.assertUpdatable( project ); + project.setName( name ); project.setScmUrl( scmUrl ); project.setNagEmailAddress( nagEmailAddress ); @@ -259,6 +252,8 @@ =20 ContinuumProject project =3D store.getContinuumProject( projec= tId, false ); =20 + projectStateGuard.assertUpdatable( project ); + project.setConfiguration( configuration ); =20 store.commit(); @@ -374,12 +369,6 @@ =20 store.commit(); =20 - for ( Iterator it =3D result.getCheckedOutFiles().iterator(); = it.hasNext(); ) - { - ScmFile scmFile =3D (ScmFile) it.next(); - System.err.println( "scmfile.path: " + scmFile.getPath() ); - } - return result; } catch ( Exception e ) @@ -403,6 +392,8 @@ =20 ContinuumProject project =3D store.getContinuumProject( projec= tId, false ); =20 + projectStateGuard.assertTransition( project, ContinuumProjectS= tate.BUILD_SIGNALED ); + project.setState( ContinuumProjectState.BUILD_SIGNALED ); =20 ContinuumBuild build =3D new ContinuumBuild(); @@ -440,6 +431,8 @@ =20 ContinuumProject project =3D build.getProject(); =20 + projectStateGuard.assertTransition( project, state ); + project.setState( state ); =20 build.setState( state ); @@ -598,7 +591,74 @@ } } =20 - public void setBuildUpdateScmResult( String buildId, UpdateScmResult s= cmResult ) + // -------------------------------------------------------------------= --- + // + // -------------------------------------------------------------------= --- + + public void setCheckoutDone( String projectId, CheckOutScmResult scmRe= sult ) + throws ContinuumStoreException + { + try + { + store.begin(); + + ContinuumProject project =3D store.getContinuumProject( projec= tId, false ); + + int state; + + if ( scmResult.isSuccess() ) + { + state =3D ContinuumProjectState.NEW; + } + else + { + state =3D ContinuumProjectState.ERROR; + } + + projectStateGuard.assertTransition( project, state ); + + project.setState( state ); + + project.setCheckOutScmResult( scmResult ); + + store.commit(); + } + catch ( Exception e ) + { + rollback( store ); + + throw new ContinuumStoreException( "Error while setting check = out scm result.", e ); + } + } + + public void setIsUpdating( String buildId ) + throws ContinuumStoreException + { + try + { + store.begin(); + + ContinuumBuild build =3D store.getContinuumBuild( buildId, fal= se ); + + ContinuumProject project =3D build.getProject(); + + projectStateGuard.assertTransition( project, ContinuumProjectS= tate.UPDATING ); + + project.setState( ContinuumProjectState.UPDATING ); + + build.setState( ContinuumProjectState.UPDATING ); + + store.commit(); + } + catch ( Exception e ) + { + rollback( store ); + + throw new ContinuumStoreException( "Error while setting build = state.", e ); + } + } + + public void setUpdateDone( String buildId, UpdateScmResult scmResult ) throws ContinuumStoreException { try @@ -609,13 +669,21 @@ =20 build.setUpdateScmResult( scmResult ); =20 + ContinuumProject project =3D build.getProject(); + + projectStateGuard.assertTransition( project, ContinuumProjectS= tate.BUILDING ); + + project.setState( ContinuumProjectState.BUILDING ); + + build.setState( ContinuumProjectState.BUILDING ); + store.commit(); } catch ( Exception e ) { rollback( store ); =20 - throw new ContinuumStoreException( "Error while setting scm up= date result for build: '" + buildId + "'.", e ); + throw new ContinuumStoreException( "Error while setting update= scm result.", e ); } } =20 Modified: maven/continuum/trunk/continuum-core/src/main/resources/META-INF/= plexus/components.xml URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src= /main/resources/META-INF/plexus/components.xml?rev=3D165648&r1=3D165647&r2= =3D165648&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus= /components.xml (original) +++ maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus= /components.xml Mon May 2 10:17:06 2005 @@ -7,26 +7,16 @@ org.apache.maven.continuum.builder.manager.BuilderManager<= /role> - org.codehaus.plexus.taskqueue.TaskQueue build-project buildQueue - org.apache.maven.continuum.store.ContinuumStore @@ -111,9 +101,17 @@ org.codehaus.plexus.jdo.JdoFactory + + org.apache.maven.continuum.project.state.ContinuumProjectS= tateGuard + =20 + + org.apache.maven.continuum.project.state.ContinuumProjectState= Guard + org.apache.maven.continuum.project.state.DefaultCont= inuumProjectStateGuard + + =20 @@ -165,8 +163,11 @@ org.apache.maven.continuum.notification.console.Cons= oleNotifier =20 - - + org.apache.maven.continuum.builder.ContinuumBuilder maven2 @@ -259,7 +260,7 @@ =20 =20 @@ -330,13 +331,20 @@ org.codehaus.plexus.taskqueue.DefaultTaskQueue plexus-configurable - + org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor check-out-project @@ -358,7 +366,7 @@ =20 @@ -402,6 +410,11 @@ =20 + org.codehaus.plexus.velocity.VelocityComponent org.codehaus.plexus.velocity.DefaultVelocityComponen= t Added: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/= continuum/DefaultContinuumTest.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src= /test/java/org/apache/maven/continuum/DefaultContinuumTest.java?rev=3D16564= 8&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/con= tinuum/DefaultContinuumTest.java (added) +++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/con= tinuum/DefaultContinuumTest.java Mon May 2 10:17:06 2005 @@ -0,0 +1,41 @@ +package org.apache.maven.continuum; + +/* + * Copyright 2004-2005 The Apache Software Foundation. + * + * Licensed 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. + */ + +import org.codehaus.plexus.PlexusTestCase; +import org.codehaus.plexus.taskqueue.TaskQueue; +import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor; + +/** + * @author Trygve Laugstøl + * @version $Id:$ + */ +public class DefaultContinuumTest + extends PlexusTestCase +{ + public void testLookups() + throws Exception + { + lookup( TaskQueue.ROLE, "build-project" ); + + lookup( TaskQueue.ROLE, "check-out-project" ); + + lookup( TaskQueueExecutor.ROLE, "build-project" ); + + lookup( TaskQueueExecutor.ROLE, "check-out-project" ); + } +} Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/mav= en/continuum/buildqueue/BuildQueueTest.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src= /test/java/org/apache/maven/continuum/buildqueue/BuildQueueTest.java?rev=3D= 165648&r1=3D165647&r2=3D165648&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/con= tinuum/buildqueue/BuildQueueTest.java (original) +++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/con= tinuum/buildqueue/BuildQueueTest.java Mon May 2 10:17:06 2005 @@ -19,6 +19,7 @@ import java.util.Properties; =20 import org.apache.maven.continuum.store.ContinuumStore; +import org.apache.maven.continuum.store.ModelloJPoxContinuumStoreTest; =20 import org.codehaus.plexus.PlexusTestCase; =20 @@ -48,7 +49,7 @@ { String name =3D "Project 1"; =20 - String project =3D createProject( name ); + String project =3D ModelloJPoxContinuumStoreTest.addProject( store= , name ); =20 String build =3D enqueue( project ); =20 @@ -75,9 +76,9 @@ =20 String name2 =3D "Project 2"; =20 - String project1 =3D createProject( name1 ); + String project1 =3D ModelloJPoxContinuumStoreTest.addProject( stor= e, name1 ); =20 - String project2 =3D createProject( name2 ); + String project2 =3D ModelloJPoxContinuumStoreTest.addProject( stor= e, name2 ); =20 String build1 =3D enqueue( project1 ); =20 @@ -112,19 +113,6 @@ // -------------------------------------------------------------------= --- // // -------------------------------------------------------------------= --- - - private String createProject( String name ) - throws Exception - { - String scmUrl =3D "scm:local:src/test/projects/project-1"; - String nagEmailAddress =3D "foo@bar"; - String version =3D "1.0"; - String builderId =3D "test"; - String workingDirectory =3D getTestPath( "target/checkouts" ); - Properties properties =3D new Properties(); - - return store.addProject( name, scmUrl, nagEmailAddress, version, b= uilderId, workingDirectory, properties ); - } =20 private String enqueue( String projectId ) throws Exception Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/mav= en/continuum/notification/ContinuumNotificationDispatcherTest.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src= /test/java/org/apache/maven/continuum/notification/ContinuumNotificationDis= patcherTest.java?rev=3D165648&r1=3D165647&r2=3D165648&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/con= tinuum/notification/ContinuumNotificationDispatcherTest.java (original) +++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/con= tinuum/notification/ContinuumNotificationDispatcherTest.java Mon May 2 10:= 17:06 2005 @@ -21,6 +21,7 @@ import org.apache.maven.continuum.project.AntProject; import org.apache.maven.continuum.project.ContinuumBuild; import org.apache.maven.continuum.store.ContinuumStore; +import org.apache.maven.continuum.store.ModelloJPoxContinuumStoreTest; =20 import org.codehaus.plexus.PlexusTestCase; =20 @@ -39,7 +40,7 @@ =20 ContinuumStore store =3D (ContinuumStore) lookup( ContinuumStore.R= OLE ); =20 - String projectId =3D store.addProject( "Test Project", "scm:local:= foo", "foo@bar", "1.0", "ant", "/tmp", new Properties() ); + String projectId =3D ModelloJPoxContinuumStoreTest.addProject( sto= re, "Test Project" ); =20 String buildId =3D store.createBuild( projectId ); =20 Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/mav= en/continuum/store/ModelloJPoxContinuumStoreTest.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src= /test/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStoreTest.j= ava?rev=3D165648&r1=3D165647&r2=3D165648&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/con= tinuum/store/ModelloJPoxContinuumStoreTest.java (original) +++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/con= tinuum/store/ModelloJPoxContinuumStoreTest.java Mon May 2 10:17:06 2005 @@ -31,6 +31,7 @@ import org.apache.maven.continuum.project.ContinuumProjectState; import org.apache.maven.continuum.scm.ScmFile; import org.apache.maven.continuum.scm.UpdateScmResult; +import org.apache.maven.continuum.scm.CheckOutScmResult; =20 import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.jdo.JdoFactory; @@ -221,7 +222,27 @@ // // ---------------------------------------------------------------= ------- =20 - assertNotNull( store.getProject( projectId ) ); + ContinuumProject project =3D store.getProject( projectId ); + + assertNotNull( project ); + + assertEquals( ContinuumProjectState.CHECKING_OUT, project.getState= () ); + + // ---------------------------------------------------------------= ------- + // + // ---------------------------------------------------------------= ------- + + CheckOutScmResult checkOutScmResult =3D new CheckOutScmResult(); + + checkOutScmResult.setSuccess( true ); + + store.setCheckoutDone( projectId, checkOutScmResult ); + + project =3D store.getProject( projectId ); + + assertNotNull( project ); + + assertEquals( ContinuumProjectState.NEW, project.getState() ); =20 // ---------------------------------------------------------------= ------- // @@ -235,7 +256,7 @@ =20 store.updateProject( projectId, name2, scmUrl2, nagEmailAddress2, = version2 ); =20 - ContinuumProject project =3D store.getProject( projectId ); + project =3D store.getProject( projectId ); =20 assertProjectEquals( projectId, name2, scmUrl2, nagEmailAddress2, = version2, builderId, workingDirectory, properties2, project ); @@ -355,6 +376,8 @@ =20 String buildId =3D store.createBuild( projectId ); =20 + store.setIsUpdating( buildId ); + UpdateScmResult updateScmResult =3D new UpdateScmResult(); =20 ScmFile file =3D new ScmFile(); @@ -363,7 +386,7 @@ =20 updateScmResult.addUpdatedFile( file ); =20 - store.setBuildUpdateScmResult( buildId, updateScmResult ); + store.setUpdateDone( buildId, updateScmResult ); =20 ContinuumBuildResult result =3D new ShellBuildResult(); =20 @@ -511,6 +534,10 @@ =20 assertEquals( ContinuumProjectState.BUILD_SIGNALED, build.getState= () ); =20 + store.setIsUpdating( buildId ); + + store.setUpdateDone( buildId, new UpdateScmResult() ); + // ---------------------------------------------------------------= ------- // Check the build result // ---------------------------------------------------------------= ------- @@ -562,8 +589,12 @@ private String addProject( String name ) throws Exception { - ContinuumStore store =3D (ContinuumStore) lookup( ContinuumStore.R= OLE ); + return addProject( (ContinuumStore) lookup( ContinuumStore.ROLE ),= name ); + } =20 + public static String addProject( ContinuumStore store, String name ) + throws Exception + { String scmUrl =3D "scm:local:src/test/repo"; String nagEmailAddress =3D "foo@bar.com"; String version =3D "1.0"; @@ -571,7 +602,21 @@ String workingDirectory =3D "/tmp"; Properties configuration =3D new Properties(); =20 - return store.addProject( name, scmUrl, nagEmailAddress, version, b= uilderId, workingDirectory, configuration ); + String projectId =3D store.addProject( name, scmUrl, nagEmailAddre= ss, version, builderId, workingDirectory, configuration ); + + CheckOutScmResult checkOutScmResult =3D new CheckOutScmResult(); + + checkOutScmResult.setSuccess( true ); + + store.setCheckoutDone( projectId, checkOutScmResult ); + + ContinuumProject project =3D store.getProject( projectId ); + + assertNotNull( project ); + + assertEquals( ContinuumProjectState.NEW, project.getState() ); + + return projectId; } =20 private void assertProjectEquals( String projectId, String name, Strin= g scmUrl, String nagEmailAddress, String version, String builderId, String = workingDirectory, Properties configuration, ContinuumProject project ) Added: maven/continuum/trunk/continuum-core/src/test/resources/org/apache/m= aven/continuum/DefaultContinuumTest.xml URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src= /test/resources/org/apache/maven/continuum/DefaultContinuumTest.xml?rev=3D1= 65648&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-core/src/test/resources/org/apache/mave= n/continuum/DefaultContinuumTest.xml (added) +++ maven/continuum/trunk/continuum-core/src/test/resources/org/apache/mave= n/continuum/DefaultContinuumTest.xml Mon May 2 10:17:06 2005 @@ -0,0 +1,11 @@ + + + + org.codehaus.plexus.notification.RecipientSource + org.apache.maven.continuum.notification.ContinuumRec= ipientSource + + nobody@localhost + + + + Modified: maven/continuum/trunk/continuum-plexus-application/src/conf/appli= cation.xml URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-plexus-a= pplication/src/conf/application.xml?rev=3D165648&r1=3D165647&r2=3D165648&vi= ew=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-plexus-application/src/conf/application= .xml (original) +++ maven/continuum/trunk/continuum-plexus-application/src/conf/application= .xml Mon May 2 10:17:06 2005 @@ -17,6 +17,14 @@ org.apache.maven.continuum.trigger.ContinuumTrigger alarm-clock + + org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor + build-project + + + org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor + check-out-project + =20 @@ -165,6 +173,9 @@ org.codehaus.plexus.jdo.JdoFactory + + + org.apache.maven.continuum.project.state.ContinuumProjectS= tateGuard Modified: maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/m= aven/continuum/xmlrpc/DefaultContinuumXmlRpc.java URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-xmlrpc/s= rc/main/java/org/apache/maven/continuum/xmlrpc/DefaultContinuumXmlRpc.java?= rev=3D165648&r1=3D165647&r2=3D165648&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/c= ontinuum/xmlrpc/DefaultContinuumXmlRpc.java (original) +++ maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/c= ontinuum/xmlrpc/DefaultContinuumXmlRpc.java Mon May 2 10:17:06 2005 @@ -405,7 +405,7 @@ =20 private Hashtable handleException( String method, Throwable throwable ) { - getLogger().error( "Error while executing '" + method + "'.", thro= wable ); +// getLogger().error( "Error while executing '" + method + "'.", th= rowable ); =20 Hashtable hashtable =3D new Hashtable(); =20