View Javadoc

1   package org.apache.continuum.buildmanager;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  import java.util.List;
24  import java.util.Map;
25  
26  import org.apache.continuum.taskqueue.BuildProjectTask;
27  import org.apache.continuum.taskqueue.CheckOutTask;
28  import org.apache.continuum.taskqueue.PrepareBuildProjectsTask;
29  import org.apache.maven.continuum.model.project.BuildDefinition;
30  import org.apache.maven.continuum.model.project.BuildQueue;
31  import org.apache.maven.continuum.model.project.Project;
32  import org.apache.maven.continuum.model.scm.ScmResult;
33  
34  /**
35   * BuildsManager. All builds whether forced or triggered will go through (or have to be added through) a builds manager.
36   *
37   * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
38   */
39  public interface BuildsManager
40  {
41      /**
42       * Build projects using their corresponding build definitions. This method adds the group of projects to the
43       * build queue of the overall queue with the least amount of tasks queued.
44       *
45       * @param projects
46       * @param projectsBuildDefinitionsMap
47       * @param trigger
48       * @param scmResultMap                TODO
49       * @param projectGroupId
50       * @throws BuildManagerException
51       */
52      void buildProjects( List<Project> projects, Map<Integer, BuildDefinition> projectsBuildDefinitionsMap, int trigger,
53                          Map<Integer, ScmResult> scmResultMap, int projectGroupId )
54          throws BuildManagerException;
55  
56      /**
57       * Build the project using the specified build definition. Adds the project to the build queue of the overall queue with the
58       * least among of tasks queued. The overall queue is chosen from the pool of queues attached to the schedule of the
59       * build definition.
60       *
61       * @param projectId
62       * @param buildDefinition
63       * @param projectName
64       * @param trigger
65       * @param scmResult       TODO
66       * @param projectGroupId
67       * @throws BuildManagerException
68       */
69      void buildProject( int projectId, BuildDefinition buildDefinition, String projectName, int trigger,
70                         ScmResult scmResult, int projectGroupId )
71          throws BuildManagerException;
72  
73      /**
74       * Adds the projects in the prepare-build-queue.
75       *
76       * @param projectsBuildDefinitionsMap
77       * @param trigger
78       * @param projectGroupId              TODO
79       * @param scmRootAddress              TODO
80       * @throws BuildManagerException
81       */
82      void prepareBuildProjects( Map<Integer, Integer> projectsBuildDefinitionsMap, int trigger, int projectGroupId,
83                                 String projectGroupName, String scmRootAddress, int scmRootId )
84          throws BuildManagerException;
85  
86      /**
87       * Adds the project to the checkout queue of the overall build queue with the least amount of tasks queued.
88       * The overall queue is chosen from the pool of queues attached to the schedule of the build definition.
89       *
90       * @param projectId
91       * @param projectName
92       * @param workingDirectory
93       * @param scmUsername
94       * @param scmPassword
95       * @param defaultBuildDefinition
96       * @throws BuildManagerException
97       */
98      void checkoutProject( int projectId, String projectName, File workingDirectory, String scmUsername,
99                            String scmPassword, BuildDefinition defaultBuildDefinition )
100         throws BuildManagerException;
101 
102     /**
103      * Cancels the specified project's build.
104      *
105      * @param projectId
106      * @return
107      * @throws BuildManagerException
108      */
109     boolean cancelBuild( int projectId )
110         throws BuildManagerException;
111 
112     /**
113      * Cancels all the builds in all the overall queues.
114      *
115      * @return
116      * @throws BuildManagerException
117      */
118     boolean cancelAllBuilds()
119         throws BuildManagerException;
120 
121     /**
122      * Cancels the current build on the specified overall queue.
123      *
124      * @param buildQueueId
125      * @return
126      * @throws BuildManagerException
127      */
128     boolean cancelBuildInQueue( int buildQueueId )
129         throws BuildManagerException;
130 
131     /**
132      * @param projectId
133      * @return
134      * @throws BuildManagerException
135      */
136     boolean cancelCheckout( int projectId )
137         throws BuildManagerException;
138 
139     /**
140      * @return
141      * @throws BuildManagerException
142      */
143     boolean cancelAllCheckouts()
144         throws BuildManagerException;
145 
146     // public boolean cancelPrepareBuild(int projectId) throws BuildManagerException;
147 
148     boolean cancelAllPrepareBuilds()
149         throws BuildManagerException;
150 
151     /**
152      * Removes the project from the build queue.
153      *
154      * @param projectId
155      * @throws BuildManagerException
156      */
157     void removeProjectFromBuildQueue( int projectId )
158         throws BuildManagerException;
159 
160     /**
161      * Removes the project built using the specified build definition from the build queue.
162      *
163      * @param projectId
164      * @param buildDefinitionId
165      * @param trigger
166      * @param projectName
167      * @param projectGroupId
168      * @throws BuildManagerException
169      */
170     void removeProjectFromBuildQueue( int projectId, int buildDefinitionId, int trigger, String projectName,
171                                       int projectGroupId )
172         throws BuildManagerException;
173 
174     // TODO: should we throw an exception when one of the projects cannot be removed?
175     /**
176      * Removes the specified projects from their build queues.
177      *
178      * @param projectIds
179      */
180     void removeProjectsFromBuildQueue( int[] projectIds );
181 
182     /**
183      * Removes a set of projects using the specified hashcodes from the build queues.
184      *
185      * @param hascodes
186      * @throws BuildManagerException
187      */
188     void removeProjectsFromBuildQueueWithHashcodes( int[] hascodes )
189         throws BuildManagerException;
190 
191     /**
192      * Removes the project from the checkout queue.
193      *
194      * @param projectId
195      * @throws BuildManagerException
196      */
197     void removeProjectFromCheckoutQueue( int projectId )
198         throws BuildManagerException;
199 
200     /**
201      * Removes the specified projects from their checkout queues.
202      *
203      * @param projectIds
204      */
205     void removeProjectsFromCheckoutQueue( int[] projectIds );
206 
207     /**
208      * Removes a set of projects using the specified hashcodes from the checkout queues.
209      *
210      * @param hashcodes
211      * @throws BuildManagerException
212      */
213     void removeProjectsFromCheckoutQueueWithHashcodes( int[] hashcodes )
214         throws BuildManagerException;
215 
216     boolean removeProjectGroupFromPrepareBuildQueue( int projectGroupId, String scmRootAddress )
217         throws BuildManagerException;
218 
219     /*void removeProjectFromPrepareBuildQueue( int projectId ) throws BuildManagerException;
220 
221 void removeProjectsFromPrepareBuildQueue( int[] projectIds ) throws BuildManagerException;*/
222 
223     /**
224      * Add an overall build queue.
225      *
226      * @param buildQueue
227      * @throws BuildManagerException TODO
228      */
229     void addOverallBuildQueue( BuildQueue buildQueue )
230         throws BuildManagerException;
231 
232     /**
233      * Remove an overall build queue.
234      *
235      * @param overallBuildQueueId
236      * @throws BuildManagerException
237      */
238     void removeOverallBuildQueue( int overallBuildQueueId )
239         throws BuildManagerException;
240 
241     /**
242      * Checks whether the project build is queued.
243      *
244      * @param projectId
245      * @return
246      * @throws BuildManagerException
247      */
248     boolean isInAnyBuildQueue( int projectId )
249         throws BuildManagerException;
250 
251     /**
252      * Checks whether the project build using the specified build definition is queued.
253      *
254      * @param projectId
255      * @param buildDefinitionId
256      * @return
257      * @throws BuildManagerException
258      */
259     boolean isInAnyBuildQueue( int projectId, int buildDefinitionId )
260         throws BuildManagerException;
261 
262     /**
263      * Checks whether the project checkout is already queued.
264      *
265      * @param projectId
266      * @return
267      * @throws BuildManagerException
268      */
269     boolean isInAnyCheckoutQueue( int projectId )
270         throws BuildManagerException;
271 
272     /**
273      * Checks if at least one of the projects is currently being checked out.
274      *
275      * @param projectIds
276      * @return
277      * @throws BuildManagerException
278      */
279     boolean isAnyProjectCurrentlyBeingCheckedOut( int[] projectIds )
280         throws BuildManagerException;
281 
282     /**
283      * Checks whether the project is already in the prepare-build queue.
284      *
285      * @param projectId
286      * @return
287      * @throws BuildManagerException
288      */
289     boolean isInPrepareBuildQueue( int projectId )
290         throws BuildManagerException;
291 
292     /**
293      * Checks whether the project is currently being built.
294      *
295      * @param projectId
296      * @return
297      * @throws BuildManagerException
298      */
299     boolean isProjectInAnyCurrentBuild( int projectId )
300         throws BuildManagerException;
301 
302     // needed in QueuesAction
303 
304     /**
305      * Returns all the build tasks currently being executed.
306      *
307      * @return
308      * @throws BuildManagerException
309      */
310     Map<String, BuildProjectTask> getCurrentBuilds()
311         throws BuildManagerException;
312 
313     /**
314      * Returns all the checkout tasks currently being executed.
315      *
316      * @return
317      * @throws BuildManagerException
318      */
319     Map<String, CheckOutTask> getCurrentCheckouts()
320         throws BuildManagerException;
321 
322     /**
323      * Returns all the overall build queues together with a list of the build tasks in it's build queue.
324      *
325      * @return
326      * @throws BuildManagerException
327      */
328     Map<String, List<BuildProjectTask>> getProjectsInBuildQueues()
329         throws BuildManagerException;
330 
331     /**
332      * Returns all the overall build queues together with a list of checkout tasks in it's checkout queue.
333      *
334      * @return
335      * @throws BuildManagerException
336      */
337     Map<String, List<CheckOutTask>> getProjectsInCheckoutQueues()
338         throws BuildManagerException;
339 
340     /**
341      * Checks whether a build is in progress.
342      *
343      * @return
344      */
345     boolean isBuildInProgress();
346 
347     /**
348      * Checks if at least one of the projects is currently building.
349      * @param projectIds
350      * @return
351      * @throws BuildManagerException
352      */
353     boolean isAnyProjectCurrentlyBuilding( int[] projectIds )
354         throws BuildManagerException;
355 
356     /**
357      * Checks whether project is currently being checked out.
358      * 
359      * @param projectId
360      * @return
361      * @throws BuildManagerException
362      */
363     boolean isProjectCurrentlyBeingCheckedOut( int projectId )
364         throws BuildManagerException;
365 
366     /**
367      * Checks whether project is currently preparing build
368      * 
369      * @param projectId
370      * @return
371      * @throws BuildManagerException
372      */
373     boolean isProjectCurrentlyPreparingBuild( int projectId )
374         throws BuildManagerException;
375 
376     /**
377      * Return currently preparing build project.
378      * @return
379      * @throws BuildManagerException
380      */
381     PrepareBuildProjectsTask getCurrentProjectInPrepareBuild()
382         throws BuildManagerException;
383 
384     /**
385      * Return all projects in prepare build queue.
386      * @return
387      * @throws BuildManagerException
388      */
389     List<PrepareBuildProjectsTask> getProjectsInPrepareBuildQueue()
390         throws BuildManagerException;
391 
392     /**
393      * Remove a project from a prepare build queue.
394      * @param projectGroupId
395      * @param scmRootId
396      * @return
397      * @throws BuildManagerException
398      */
399     boolean removeProjectFromPrepareBuildQueue( int projectGroupId, int scmRootId )
400         throws BuildManagerException;
401 
402     /**
403      * Removes a set of projects using the specified hashcodes from the prepare build queues.
404      *
405      * @param hashcodes
406      * @throws BuildManagerException
407      */
408     void removeProjectsFromPrepareBuildQueueWithHashCodes( int[] hashCodes )
409         throws BuildManagerException;
410 }