Subversion Repositories DevTools

Rev

Rev 7080 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7080 Rev 7081
Line 11... Line 11...
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
 * 
14
 * 
15
 * There are three types of exclusion
15
 * There are three types of exclusion
16
 * Errors detected during planing. They may go away on the next plan
16
 * Package Errors. Errors detected during planing. They may go away on the next plan
17
 *      These are 'hard' errors
17
 *      These are 'hard' errors
18
 *          Have a rootCase string
18
 *          Have a rootCase string
19
 *          Have a null rootId
19
 *          Have a null rootId
20
 *          
20
 *          
21
 * Build Errors
21
 * Build Errors
Line 35... Line 35...
35
   * @attribute
35
   * @attribute
36
   */
36
   */
37
  private static final Logger mLogger = LoggerFactory.getLogger(BuildExclusion.class);
37
  private static final Logger mLogger = LoggerFactory.getLogger(BuildExclusion.class);
38
 
38
 
39
  /**The pvid of the package being excluded
39
  /**The pvid of the package being excluded
40
   * @attribute
-
 
41
   */
40
   */
42
  public int mId;
41
  public int mId;
43
 
42
 
44
  /**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
45
   * 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
46
   * @attribute
45
   * A Value of -2 indicates that cause is a RippleStop
47
   */
46
   */
48
  public int mRootId;
47
  private int mRootId;
49
 
48
 
50
  /**root cause
49
  /**root cause
51
   * 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
52
   * @attribute
-
 
53
   */
51
   */
54
  public String mRootCause;
52
  private String mRootCause;
55
 
53
 
56
  /**test build instruction
54
  /**test build instruction
57
   * @attribute
55
   * Associated package is a test build
58
   */
56
   */
59
  private int mTestBuildInstruction;
57
  private int mTestBuildInstruction;
60
 
58
 
61
  /**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
62
   * @attribute
63
   *    
63
   */
64
   */
64
  private boolean mProcessed = false;
65
  private boolean mProcessed = false;
65
  
66
  
66
  /** Indicates that the entry was imported from the database
67
  /** Indicates that the entry was imported from the database
67
   *  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 96... Line 97...
96
  /** @returns true if the item has been marked as processed. 
97
  /** @returns true if the item has been marked as processed. 
97
   * Appears to be an indication that the entry has been superseded.
98
   * Appears to be an indication that the entry has been superseded.
98
   */
99
   */
99
  boolean isProcessed()
100
  boolean isProcessed()
100
  {
101
  {
101
    mLogger.debug("isProcessed {}", mId);
-
 
102
    mLogger.info("isProcessed returned {}", mProcessed);
102
    mLogger.debug("isProcessed returned {}", mProcessed);
103
    return mProcessed;
103
    return mProcessed;
104
  }
104
  }
105
  
105
  
106
  /** Flag as an imported entry
106
  /** Flag as an imported entry
107
   *  Used to detect indirect exclusions that are no longer valid
107
   *  Used to detect indirect exclusions that are no longer valid
Line 118... Line 118...
118
  {
118
  {
119
      return mImported;
119
      return mImported;
120
  }
120
  }
121
  
121
  
122
  /**
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
  /**
123
   * Compare this item with parameters
159
   * Compare this item with parameters
124
   * @param identifier          - Related Package identifier
160
   * @param identifier          - Related Package identifier
125
   * @param rootIdentifier      - Package identifier of root cause
161
   * @param rootIdentifier      - Package identifier of root cause
126
   * @param  rootCause          - Root cause string. May be null
162
   * @param  rootCause          - Root cause string. May be null
127
   * @return true if all attributes match
163
   * @return true if all attributes match
Line 149... Line 185...
149
    
185
    
150
    mLogger.info("compare returned {}", retVal);
186
    mLogger.info("compare returned {}", retVal);
151
    return retVal;
187
    return retVal;
152
  }
188
  }
153
  
189
  
-
 
190
  /**   Does this entry relate to the package with a specified mId
154
  /**
191
   * 
155
   * @param identifier  - identifier to match
192
   * @param identifier  - Package Identifier (mId) to match
156
   * @return true if mId attribute matches
193
   * @return true if mId attribute matches
157
   */
194
   */
158
  boolean compare( int identifier )
195
  boolean compare( int identifier )
159
  {
196
  {
160
    mLogger.debug("compare {},{}", mId,  identifier);
197
    mLogger.debug("compare {},{}", mId,  identifier);
Line 202... Line 239...
202
  void includeToBuild( ReleaseManager rm, int rtagId ) throws SQLException, Exception
239
  void includeToBuild( ReleaseManager rm, int rtagId ) throws SQLException, Exception
203
  {
240
  {
204
    mLogger.debug("includeToBuild {}", mId);
241
    mLogger.debug("includeToBuild {}", mId);
205
    rm.includeToBuild(mId, rtagId);
242
    rm.includeToBuild(mId, rtagId);
206
  }
243
  }
207
  
-
 
208
  /**
-
 
209
   * Match this items id against that provided
-
 
210
   * @param id  - Id to match
-
 
211
   * @return true if id matches mId
-
 
212
   */
-
 
213
    private boolean isRelevant(int id)
-
 
214
    {
-
 
215
      mLogger.debug("isRelevant {},{}", mId, id);
-
 
216
      boolean retVal = false;
-
 
217
      
-
 
218
      if ( mId == id )
-
 
219
      {
-
 
220
        retVal = true;
-
 
221
      }
-
 
222
 
-
 
223
      mLogger.info("isRelevant {},{}, returned {}",  mId,  id, retVal);
-
 
224
      return retVal;
-
 
225
    }
-
 
226
    
244
    
227
  /**
245
  /**
228
   * 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
229
   * 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
230
   * 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 237... Line 255...
237
  {
255
  {
238
    mLogger.debug("isRelevant {}", mId);
256
    mLogger.debug("isRelevant {}", mId);
239
    boolean retVal = false;
257
    boolean retVal = false;
240
    
258
    
241
    if ( mRootId == -1 )     {
259
    if ( mRootId == -1 )     {
-
 
260
        // This is a Build or Package Error
242
      retVal = true;
261
        retVal = true;
243
      
262
      
244
    } else if(mRootId == -2 ) {
263
    } else if(mRootId == -2 ) {
245
        // Excluded due to Ripple Stop
264
        // Excluded due to Ripple Stop
246
        // Will be recalculated so its not relevant
265
        // Will be recalculated so its not relevant
247
        retVal = false;
266
        retVal = false;
248
        
267
        
249
    } else {
268
    } else {
250
        
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
        
251
      retVal = false;
274
      retVal = false;
252
      for (Iterator<BuildExclusion> it = buildExclusionCollection.iterator(); it.hasNext(); )
275
      for (Iterator<BuildExclusion> it = buildExclusionCollection.iterator(); it.hasNext(); )
253
      {
276
      {
254
        BuildExclusion buildExclusion = it.next();
277
        BuildExclusion buildExclusion = it.next();
255
        
278
        
256
        if ( buildExclusion.isRelevant( mRootId ) )
279
        if ( buildExclusion.mRootId == mRootId )
257
        {
280
        {
258
          retVal = true;
281
          retVal = true;
259
          break;
282
          break;
260
        }
283
        }
261
      }
284
      }
Line 263... Line 286...
263
 
286
 
264
    mLogger.info("isRelevant {} returned {}", mId, retVal);
287
    mLogger.info("isRelevant {} returned {}", mId, retVal);
265
    return retVal;
288
    return retVal;
266
  }
289
  }
267
 
290
 
268
  /**
-
 
269
   * @return true if the root_pv_id is null (-1). This indicates that the item is the root case, and is not simply
-
 
270
   *         a by product of some other cause.
-
 
271
   */
-
 
272
  boolean isARootCause()
-
 
273
  {
291
  
274
    mLogger.debug("isARootCause {}", mId);
-
 
275
    boolean retVal = false;
-
 
276
    
-
 
277
    if ( mRootId == -1 )
-
 
278
    {
-
 
279
      retVal = true;
-
 
280
    }
-
 
281
 
-
 
282
    mLogger.info("isARootCause {} returned {}",mId, retVal);
-
 
283
    return retVal;
-
 
284
  }
-
 
285
 
292
 
286
  /**
293
  /**
287
   * Send an email notifying users about a build excluded package
294
   * Send an email notifying users about a build excluded package
288
   * 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 
289
   * 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 302... Line 309...
302
      //    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
303
      //    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
304
      //    Direct build failure: 
311
      //    Direct build failure: 
305
      //        Have no RootId and have a rootCause
312
      //        Have no RootId and have a rootCause
306
      //
313
      //
307
      if ( mRootId == -1 && mRootCause != null )
314
      if ( isAPackageError() )
308
      {
315
      {
309
        //  Locate the associated package entry
316
        //  Locate the associated package entry
310
        Package pkg= rippleEngine.mReleaseManager.findPackage(mId, packageCollection);
317
        Package pkg= rippleEngine.mReleaseManager.findPackage(mId, packageCollection);
311
        
318
        
312
        if ( pkg != ReleaseManager.NULL_PACKAGE )
319
        if ( pkg != ReleaseManager.NULL_PACKAGE )
Line 375... Line 382...
375
      return retVal;
382
      return retVal;
376
    }
383
    }
377
 
384
 
378
    /**
385
    /**
379
     * Generate a single text line of info
386
     * Generate a single text line of info
380
     * Used within the UTF to 
387
     * Used within the UTF to display diagnostic info
381
     * @return String form of the state of the entry
388
     * @return String form of the state of the entry
382
     */
389
     */
383
    public String info()
390
    public String toString()
384
    {
391
    {
385
        String rv = "";
392
        String rv = "";
386
        rv += "pvid=" + mId + ",RootId=" + mRootId + ",Processed=" + mProcessed + ",TestBuild=" + mTestBuildInstruction + ",RootCause=" + mRootCause;
393
        rv += "pvid=" + mId + ",RootId=" + mRootId + ",Processed=" + mProcessed + ",TestBuild=" + mTestBuildInstruction + ",RootCause=" + mRootCause;
387
        if ( mImported ) {
394
        if ( mImported ) {
388
            rv += ",Imported=" + mImported;
395
            rv += ",Imported=" + mImported;