You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by oc...@apache.org on 2008/12/02 02:12:22 UTC
svn commit: r722321 - in
/continuum/branches/continuum-parallel-builds/continuum-core/src:
main/java/org/apache/continuum/taskqueue/
main/java/org/apache/continuum/taskqueue/manager/
test/java/org/apache/continuum/taskqueue/
Author: oching
Date: Mon Dec 1 17:12:22 2008
New Revision: 722321
URL: http://svn.apache.org/viewvc?rev=722321&view=rev
Log:
-added "overall" build queue impl
Added:
continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/DefaultOverallQueue.java
continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/OverallQueue.java
continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/taskqueue/
continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/taskqueue/DefaultOverallQueueTest.java
Modified:
continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java
Added: continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/DefaultOverallQueue.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/DefaultOverallQueue.java?rev=722321&view=auto
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/DefaultOverallQueue.java (added)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/DefaultOverallQueue.java Mon Dec 1 17:12:22 2008
@@ -0,0 +1,86 @@
+package org.apache.continuum.taskqueue;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.continuum.taskqueue.manager.TaskQueueManager;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.taskqueue.Task;
+
+/**
+ * "Overall" queue which handles
+ *
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ * @plexus.component role="org.apache.continuum.taskqueue.OverallQueue"
+ */
+public class DefaultOverallQueue
+ extends AbstractLogEnabled
+ implements OverallQueue
+{
+ /**
+ * @plexus.requirement
+ *
+ * TODO: this should not be a singleton now!
+ */
+ private TaskQueueManager taskQueueManager;
+
+ public void addToPrepareBuildProjectsQueue( Task prepareBuildTask )
+ throws Exception
+ {
+ if( prepareBuildTask != null )
+ {
+ taskQueueManager.getPrepareBuildQueue().put( prepareBuildTask );
+ }
+ else
+ {
+ getLogger().warn( "Cannot add task to prepare-build-project queue." );
+ }
+ }
+
+ public void addToBuildQueue( Task buildTask )
+ throws Exception
+ {
+ if( buildTask != null )
+ {
+ taskQueueManager.getBuildQueue().put( buildTask );
+ }
+ else
+ {
+ getLogger().warn( "Cannot add task to build-project queue." );
+ }
+ }
+
+ public void addToCheckoutQueue( Task checkoutTask )
+ throws Exception
+ {
+ if( checkoutTask != null )
+ {
+ taskQueueManager.getCheckoutQueue().put( checkoutTask );
+ }
+ else
+ {
+ getLogger().warn( "Cannot add task to checkout queue." );
+ }
+ }
+
+ public TaskQueueManager getTaskQueueManager()
+ {
+ return taskQueueManager;
+ }
+}
Added: continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/OverallQueue.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/OverallQueue.java?rev=722321&view=auto
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/OverallQueue.java (added)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/OverallQueue.java Mon Dec 1 17:12:22 2008
@@ -0,0 +1,34 @@
+package org.apache.continuum.taskqueue;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.continuum.taskqueue.manager.TaskQueueManager;
+import org.codehaus.plexus.taskqueue.Task;
+
+public interface OverallQueue
+{
+ public void addToCheckoutQueue( Task checkoutTask ) throws Exception;
+
+ public void addToPrepareBuildProjectsQueue( Task prepareBuildTask ) throws Exception;
+
+ public void addToBuildQueue( Task buildTask ) throws Exception;
+
+ public TaskQueueManager getTaskQueueManager();
+}
Modified: continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java?rev=722321&r1=722320&r2=722321&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java (original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java Mon Dec 1 17:12:22 2008
@@ -34,7 +34,8 @@
/**
* @author <a href="mailto:ctan@apache.org">Maria Catherine Tan</a>
- * @plexus.component role="org.apache.continuum.taskqueue.manager.TaskQueueManager" role-hint="default"
+ * @plexus.component role="org.apache.continuum.taskqueue.manager.TaskQueueManager" role-hint="default"
+ * instantiation-strategy="per-lookup"
*/
public class DefaultTaskQueueManager
extends AbstractLogEnabled
Added: continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/taskqueue/DefaultOverallQueueTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/taskqueue/DefaultOverallQueueTest.java?rev=722321&view=auto
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/taskqueue/DefaultOverallQueueTest.java (added)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/taskqueue/DefaultOverallQueueTest.java Mon Dec 1 17:12:22 2008
@@ -0,0 +1,84 @@
+package org.apache.continuum.taskqueue;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.maven.continuum.AbstractContinuumTest;
+import org.apache.maven.continuum.buildqueue.BuildProjectTask;
+import org.apache.maven.continuum.scm.queue.CheckOutTask;
+import org.apache.maven.continuum.scm.queue.PrepareBuildProjectsTask;
+
+public class DefaultOverallQueueTest
+ extends AbstractContinuumTest
+{
+ private OverallQueue overallQueue;
+
+ @Override
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ overallQueue = ( OverallQueue ) lookup( OverallQueue.class );
+ }
+
+ public void testAddToCheckoutQueue()
+ throws Exception
+ {
+ File workingDir = new File( getBasedir(), "target/working-dir" );
+
+ CheckOutTask task = new CheckOutTask( 1, workingDir, "continuum-test-project", "username", "password" );
+ overallQueue.addToCheckoutQueue( task );
+
+ CheckOutTask queuedTask = ( CheckOutTask ) overallQueue.getTaskQueueManager().getCheckoutQueue().take();
+ assertNotNull( queuedTask );
+ assertEquals( 1, queuedTask.getProjectId() );
+ assertEquals( "continuum-test-project", queuedTask.getProjectName() );
+ }
+
+ public void testAddToBuildQueue()
+ throws Exception
+ {
+ BuildProjectTask buildTask = new BuildProjectTask( 1, 1, 1, "continuum-test-project", "build-def-label" );
+ overallQueue.addToBuildQueue( buildTask );
+
+ BuildProjectTask queuedTask = ( BuildProjectTask ) overallQueue.getTaskQueueManager().getBuildQueue().take();
+ assertNotNull( queuedTask );
+ assertEquals( 1, queuedTask.getProjectId() );
+ assertEquals( "continuum-test-project", queuedTask.getProjectName() );
+ }
+
+ public void testAddToPrepareBuildQueue()
+ throws Exception
+ {
+ Map<Integer, Integer> projectsBuildDefMap = new HashMap<Integer, Integer>();
+ projectsBuildDefMap.put( new Integer( 1 ), new Integer( 1 ) );
+
+ PrepareBuildProjectsTask prepareBuildTask = new PrepareBuildProjectsTask( projectsBuildDefMap, 1 );
+ overallQueue.addToPrepareBuildProjectsQueue( prepareBuildTask );
+
+ PrepareBuildProjectsTask queuedTask = ( PrepareBuildProjectsTask ) overallQueue.getTaskQueueManager().getPrepareBuildQueue().take();
+ assertNotNull( queuedTask );
+ assertEquals( 1, ( ( Integer )queuedTask.getProjectsBuildDefinitionsMap().get( new Integer( 1 ) ) ).intValue() );
+ }
+}