Subversion Repositories DevTools

Rev

Rev 7033 | Rev 7155 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7033 Rev 7082
Line 9... Line 9...
9
import java.sql.SQLException;
9
import java.sql.SQLException;
10
import java.util.ArrayList;
10
import java.util.ArrayList;
11
import java.util.Iterator;
11
import java.util.Iterator;
12
 
12
 
13
/**entity class holding build exclusion data
13
/**entity class holding build exclusion data
-
 
14
 * 
-
 
15
 * There are three types of exclusion
-
 
16
 * Package Errors. Errors detected during planing. They may go away on the next plan
-
 
17
 *      These are 'hard' errors
-
 
18
 *          Have a rootCase string
-
 
19
 *          Have a null rootId
-
 
20
 *          
-
 
21
 * Build Errors
-
 
22
 *      These are persistent errors
-
 
23
 *          Have a null rootCause
-
 
24
 *          Have a null rootId
-
 
25
 *          Have a non-null root_file
-
 
26
 *          
-
 
27
 *  Indirect errors
-
 
28
 *      These are packages that depend on excluded packages
-
 
29
 *          Will have a non-null rootId          
-
 
30
 * 
14
 */
31
 */
15
public class BuildExclusion
32
public class BuildExclusion
16
{
33
{
17
  /**Logger
34
  /**Logger
18
   * @attribute
35
   * @attribute
19
   */
36
   */
20
  private static final Logger mLogger = LoggerFactory.getLogger(BuildExclusion.class);
37
  private static final Logger mLogger = LoggerFactory.getLogger(BuildExclusion.class);
21
 
38
 
22
  /**The pvid of the package being excluded
39
  /**The pvid of the package being excluded
23
   * @attribute
-
 
24
   */
40
   */
25
  private int mId;
41
  public int mId;
26
 
42
 
27
  /**root identifier is the PVID of the package that is causing the exclusion
43
  /**root identifier is the PVID of the package that is causing the exclusion
28
   * A NULL value indicates that this entry(package) is the root cause of the of an exclusion
44
   * A NULL (-1) value indicates that this entry(package) is the root cause of the of an exclusion
29
   * @attribute
45
   * A Value of -2 indicates that cause is a RippleStop
30
   */
46
   */
31
  private int mRootId;
47
  private int mRootId;
32
 
48
 
33
  /**root cause
49
  /**root cause
34
   * If not NULL, then this is the reason this package is being excluded
50
   * If not NULL, then this is the reason this package is being excluded
35
   * @attribute
-
 
36
   */
51
   */
37
  private String mRootCause;
52
  private String mRootCause;
38
 
53
 
39
  /**test build instruction
54
  /**test build instruction
40
   * @attribute
55
   * Associated package is a test build
41
   */
56
   */
42
  private int mTestBuildInstruction;
57
  private int mTestBuildInstruction;
43
 
58
 
44
  /**Indicates that the item has been processed
59
  /** Indicates that the error associated with this package has been seen again
-
 
60
   *  Set if we discover 'Package Error'
-
 
61
   *  
-
 
62
   *  Used to determine if a 'Package Error' should be removed
45
   * @attribute
63
   *    
46
   */
64
   */
47
  private boolean mProcessed = false;
65
  private boolean mProcessed = false;
48
  
66
  
49
  /** Indicates that the entry was imported from the database
67
  /** Indicates that the entry was imported from the database
50
   *  Used to determine entries that are no-longer needed and can be removed from the database
68
   *  Used to determine entries that are no-longer needed and can be removed from the database
Line 79... Line 97...
79
  /** @returns true if the item has been marked as processed. 
97
  /** @returns true if the item has been marked as processed. 
80
   * Appears to be an indication that the entry has been superseded.
98
   * Appears to be an indication that the entry has been superseded.
81
   */
99
   */
82
  boolean isProcessed()
100
  boolean isProcessed()
83
  {
101
  {
84
    mLogger.debug("isProcessed {}", mId);
-
 
85
    mLogger.info("isProcessed returned {}", mProcessed);
102
    mLogger.debug("isProcessed returned {}", mProcessed);
86
    return mProcessed;
103
    return mProcessed;
87
  }
104
  }
88
  
105
  
89
  /** Flag as an imported entry
106
  /** Flag as an imported entry
90
   *  Used to detect indirect exclusions that are no longer valid
107
   *  Used to detect indirect exclusions that are no longer valid
Line 101... Line 118...
101
  {
118
  {
102
      return mImported;
119
      return mImported;
103
  }
120
  }
104
  
121
  
105
  /**
122
  /**
-
 
123
   * Determine the entry type
-
 
124
   * Have three types - see class comments above
-
 
125
   */
-
 
126
  boolean isAPackageError()
-
 
127
  {
-
 
128
      return (mRootCause != null && mRootId < 0);
-
 
129
  }
-
 
130
  
-
 
131
  boolean isABuildError()
-
 
132
  {
-
 
133
      return (mRootCause == null && mRootId < 0);
-
 
134
  }
-
 
135
  
-
 
136
  boolean isAIndirectError()
-
 
137
  {
-
 
138
      return (mRootId >= 0);
-
 
139
  }
-
 
140
  
-
 
141
  /**
-
 
142
   * @return true if this item is the root case, and is not simply a by product of some other cause.
-
 
143
   * This is the same as !isAIndirectError() 
-
 
144
   */
-
 
145
  boolean isARootCause()
-
 
146
  {
-
 
147
    boolean retVal = false;
-
 
148
    
-
 
149
    if ( mRootId == -1 )
-
 
150
    {
-
 
151
      retVal = true;
-
 
152
    }
-
 
153
 
-
 
154
    mLogger.info("isARootCause {} returned {}",mId, retVal);
-
 
155
    return retVal;
-
 
156
  }
-
 
157
  
-
 
158
  /**
106
   * Compare this item with parameters
159
   * Compare this item with parameters
107
   * @param identifier          - Related Package identifier
160
   * @param identifier          - Related Package identifier
108
   * @param rootIdentifier      - Package identifier of root cause
161
   * @param rootIdentifier      - Package identifier of root cause
109
   * @param  rootCause          - Root cause string. May be null
162
   * @param  rootCause          - Root cause string. May be null
110
   * @return true if all attributes match
163
   * @return true if all attributes match
Line 132... Line 185...
132
    
185
    
133
    mLogger.info("compare returned {}", retVal);
186
    mLogger.info("compare returned {}", retVal);
134
    return retVal;
187
    return retVal;
135
  }
188
  }
136
  
189
  
-
 
190
  /**   Does this entry relate to the package with a specified mId
137
  /**
191
   * 
138
   * @param identifier  - identifier to match
192
   * @param identifier  - Package Identifier (mId) to match
139
   * @return true if mId attribute matches
193
   * @return true if mId attribute matches
140
   */
194
   */
141
  boolean compare( int identifier )
195
  boolean compare( int identifier )
142
  {
196
  {
143
    mLogger.debug("compare {},{}", mId,  identifier);
197
    mLogger.debug("compare {},{}", mId,  identifier);
Line 185... Line 239...
185
  void includeToBuild( ReleaseManager rm, int rtagId ) throws SQLException, Exception
239
  void includeToBuild( ReleaseManager rm, int rtagId ) throws SQLException, Exception
186
  {
240
  {
187
    mLogger.debug("includeToBuild {}", mId);
241
    mLogger.debug("includeToBuild {}", mId);
188
    rm.includeToBuild(mId, rtagId);
242
    rm.includeToBuild(mId, rtagId);
189
  }
243
  }
190
  
-
 
191
  /**
-
 
192
   * Match this items id against that provided
-
 
193
   * @param id  - Id to match
-
 
194
   * @return true if id matches mId
-
 
195
   */
-
 
196
    private boolean isRelevant(int id)
-
 
197
    {
-
 
198
      mLogger.debug("isRelevant {},{}", mId, id);
-
 
199
      boolean retVal = false;
-
 
200
      
-
 
201
      if ( mId == id )
-
 
202
      {
-
 
203
        retVal = true;
-
 
204
      }
-
 
205
 
-
 
206
      mLogger.info("isRelevant {},{}, returned {}",  mId,  id, retVal);
-
 
207
      return retVal;
-
 
208
    }
-
 
209
    
244
    
210
  /**
245
  /**
211
   * Match this items mRootId against the id's provided in a collection
246
   * Match this items mRootId against the id's provided in a collection
212
   * ie: Determine if any items in the collection are the root cause of this items
247
   * ie: Determine if any items in the collection are the root cause of this items
213
   * ie: Used to determine if an entry is for an indirectly excluded package where
248
   * ie: Used to determine if an entry is for an indirectly excluded package where
Line 220... Line 255...
220
  {
255
  {
221
    mLogger.debug("isRelevant {}", mId);
256
    mLogger.debug("isRelevant {}", mId);
222
    boolean retVal = false;
257
    boolean retVal = false;
223
    
258
    
224
    if ( mRootId == -1 )     {
259
    if ( mRootId == -1 )     {
-
 
260
        // This is a Build or Package Error
225
      retVal = true;
261
        retVal = true;
226
      
262
      
227
    } else if(mRootId == -2 ) {
263
    } else if(mRootId == -2 ) {
228
        // Excluded due to Ripple Stop
264
        // Excluded due to Ripple Stop
229
        // Will be recalculated so its not relevant
265
        // Will be recalculated so its not relevant
230
        retVal = false;
266
        retVal = false;
231
        
267
        
232
    } else {
268
    } else {
233
        
269
        
-
 
270
        //
-
 
271
        //  Must be an indirect exclusion
-
 
272
        //  Scan to see if the rootCause is still present. It may have been removed by the user
-
 
273
        
234
      retVal = false;
274
      retVal = false;
235
      for (Iterator<BuildExclusion> it = buildExclusionCollection.iterator(); it.hasNext(); )
275
      for (Iterator<BuildExclusion> it = buildExclusionCollection.iterator(); it.hasNext(); )
236
      {
276
      {
237
        BuildExclusion buildExclusion = it.next();
277
        BuildExclusion buildExclusion = it.next();
238
        
278
        
239
        if ( buildExclusion.isRelevant( mRootId ) )
279
        if ( buildExclusion.mRootId == mRootId )
240
        {
280
        {
241
          retVal = true;
281
          retVal = true;
242
          break;
282
          break;
243
        }
283
        }
244
      }
284
      }
Line 246... Line 286...
246
 
286
 
247
    mLogger.info("isRelevant {} returned {}", mId, retVal);
287
    mLogger.info("isRelevant {} returned {}", mId, retVal);
248
    return retVal;
288
    return retVal;
249
  }
289
  }
250
 
290
 
251
  /**
-
 
252
   * @return true if the root_pv_id is null (-1). This indicates that the item is the root case, and is not simply
-
 
253
   *         a by product of some other cause.
-
 
254
   */
-
 
255
  boolean isARootCause()
-
 
256
  {
291
  
257
    mLogger.debug("isARootCause {}", mId);
-
 
258
    boolean retVal = false;
-
 
259
    
-
 
260
    if ( mRootId == -1 )
-
 
261
    {
-
 
262
      retVal = true;
-
 
263
    }
-
 
264
 
-
 
265
    mLogger.info("isARootCause {} returned {}",mId, retVal);
-
 
266
    return retVal;
-
 
267
  }
-
 
268
 
292
 
269
  /**
293
  /**
270
   * Send an email notifying users about a build excluded package
294
   * Send an email notifying users about a build excluded package
271
   * It is user friendly, in that it does not trigger a storm of emails because a low level package 
295
   * It is user friendly, in that it does not trigger a storm of emails because a low level package 
272
   * has a build issue. It limits the emails to the low level package
296
   * has a build issue. It limits the emails to the low level package
Line 285... Line 309...
285
      //    Only process entries that are direct failures of ripple engine detected failure
309
      //    Only process entries that are direct failures of ripple engine detected failure
286
      //    Do not process entries that are indirectly excluded as this will cause an email storm
310
      //    Do not process entries that are indirectly excluded as this will cause an email storm
287
      //    Direct build failure: 
311
      //    Direct build failure: 
288
      //        Have no RootId and have a rootCause
312
      //        Have no RootId and have a rootCause
289
      //
313
      //
290
      if ( mRootId == -1 && mRootCause != null )
314
      if ( isAPackageError() )
291
      {
315
      {
292
        //  Locate the associated package entry
316
        //  Locate the associated package entry
293
        Package pkg= rippleEngine.mReleaseManager.findPackage(mId, packageCollection);
317
        Package pkg= rippleEngine.mReleaseManager.findPackage(mId, packageCollection);
294
        
318
        
295
        if ( pkg != ReleaseManager.NULL_PACKAGE )
319
        if ( pkg != ReleaseManager.NULL_PACKAGE )
Line 358... Line 382...
358
      return retVal;
382
      return retVal;
359
    }
383
    }
360
 
384
 
361
    /**
385
    /**
362
     * Generate a single text line of info
386
     * Generate a single text line of info
363
     * Used within the UTF to 
387
     * Used within the UTF to display diagnostic info
364
     * @return String form of the state of the entry
388
     * @return String form of the state of the entry
365
     */
389
     */
366
    public String info()
390
    public String toString()
367
    {
391
    {
368
        String rv = "";
392
        String rv = "";
369
        rv += "pvid=" + mId + ",RootId=" + mRootId + ",Processed=" + mProcessed + ",TestBuild=" + mTestBuildInstruction + ",RootCause=" + mRootCause;
393
        rv += "pvid=" + mId + ",RootId=" + mRootId + ",Processed=" + mProcessed + ",TestBuild=" + mTestBuildInstruction + ",RootCause=" + mRootCause;
370
        if ( mImported ) {
394
        if ( mImported ) {
371
            rv += ",Imported=" + mImported;
395
            rv += ",Imported=" + mImported;